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

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Siiri Tann

See merge request teis/officials-service!62
parents 9ce4c7e6 e9f885a6
# Changelog
## [1.13.0] - 2021-12-16
* TEIS-2498: Added functionality for updating microservices database cache via RabbitMQ batch messages. Implemented
execution lock functionality to enable specific processes to be processed by single Kubernetes pods
* TEIS-2599: security and metrics update
## [1.12.0] - 2021-09-27
* Added OfficeService to take use of database cached offices; refactored code (moved office related cache classes to separate office package)
......
theGroup=ee.sm.ti.teis
theVersion=1.12.0
commonsVersion=1.27.0
officeApiGatewayVersion=1.27.0
pluginVersion=1.3.0
theVersion=1.13.0
commonsVersion=1.28.0
officeApiGatewayVersion=1.28.0
pluginVersion=1.4.1
......@@ -122,7 +122,7 @@ class DeleteOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
@Override
@Test
public void missingPrivilege_forbidden() {
public void missingRequiredPrivilege_forbidden() {
requestMetaDTO.setPrivileges(emptyList());
request.setPayload(randomUUID(), requestMetaDTO);
......
......@@ -148,7 +148,7 @@ class UpdateOfficialInSequenceGwListenerTest extends OfficialsAppTestBase implem
@Override
@Test
public void missingPrivilege_forbidden() {
public void missingRequiredPrivilege_forbidden() {
requestMetaDTO.setPrivileges(emptyList());
request.setPayload(new UpdateOfficialInSequenceDto(randomUUID(), true), requestMetaDTO);
......
......@@ -25,11 +25,17 @@ import static org.assertj.core.api.Assertions.assertThat;
class OfficialsSequenceGwListenerTest extends OfficialsAppTestBase implements ListenerGetObjectRequestTestBase {
GetOfficialsSequenceRequest request;
RequestMetaDTO requestMetaDTO;
private static final UUID OFFICIAL_USER_ID = UUID.fromString("3dac227f-a8af-4771-8d8b-01409ac7fef0");
private static final String ID_CODE = "38909120274";
private static final String FIRST_NAME = "Esimene";
private static final String LAST_NAME = "Test-Kasutaja";
@Autowired
private OfficialsSequenceGwListener listener;
GetOfficialsSequenceRequest request;
RequestMetaDTO requestMetaDTO;
@BeforeEach
void setUp() {
requestMetaDTO = createRequestMeta(randomUUID().toString(), OFFICIAL_USER, randomUUID().toString(), List.of(TI_VIEW_OFFICIALS_SEQUENCES.name()));
......@@ -72,11 +78,11 @@ class OfficialsSequenceGwListenerTest extends OfficialsAppTestBase implements Li
.officialsInSequence(List.of(
OfficialUserInSequenceDetailsDto.builder()
.id(UUID.fromString("9d647f88-81bb-429f-8052-6a19d96a3644"))
.officialUserId(UUID.fromString("3dac227f-a8af-4771-8d8b-01409ac7fef0"))
.officialUserId(OFFICIAL_USER_ID)
.active(false)
.idCode("38909120274")
.firstName("Esimene")
.lastName("Test-Kasutaja")
.idCode(ID_CODE)
.firstName(FIRST_NAME)
.lastName(LAST_NAME)
.build()))
.build();
assertThat(response.getPayload()).isEqualTo(dto);
......@@ -100,15 +106,15 @@ class OfficialsSequenceGwListenerTest extends OfficialsAppTestBase implements Li
.active(false)
.idCode("37802170149")
.firstName("Kolmas")
.lastName("Test-Kasutaja")
.lastName(LAST_NAME)
.build(),
OfficialUserInSequenceDetailsDto.builder()
.id(UUID.fromString("122eddbd-50aa-4b6c-b3c7-fadf385b3fc2"))
.officialUserId(UUID.fromString("3dac227f-a8af-4771-8d8b-01409ac7fef0"))
.officialUserId(OFFICIAL_USER_ID)
.active(true)
.idCode("38909120274")
.firstName("Esimene")
.lastName("Test-Kasutaja")
.idCode(ID_CODE)
.firstName(FIRST_NAME)
.lastName(LAST_NAME)
.build()
))
.build();
......@@ -157,11 +163,11 @@ class OfficialsSequenceGwListenerTest extends OfficialsAppTestBase implements Li
.lastSelectedOfficialId(null)
.officialsInSequence(List.of(OfficialUserInSequenceDetailsDto.builder()
.id(UUID.fromString("16b34bc7-a28a-42cb-891c-2af9ad40c3f4"))
.officialUserId(UUID.fromString("3dac227f-a8af-4771-8d8b-01409ac7fef0"))
.officialUserId(OFFICIAL_USER_ID)
.active(false)
.idCode("38909120274")
.firstName("Esimene")
.lastName("Test-Kasutaja")
.idCode(ID_CODE)
.firstName(FIRST_NAME)
.lastName(LAST_NAME)
.build()))
.build();
assertThat(response.getPayload()).isEqualTo(dto);
......@@ -169,7 +175,7 @@ class OfficialsSequenceGwListenerTest extends OfficialsAppTestBase implements Li
@Override
@Test
public void missingPrivilege_forbidden() {
public void missingRequiredPrivilege_forbidden() {
requestMetaDTO.setPrivileges(emptyList());
request.setPayload(randomUUID(), requestMetaDTO);
......
......@@ -91,7 +91,7 @@ class OfficialsSequencesGwListenerTest extends OfficialsAppTestBase implements L
@Override
@Test
public void missingPrivilege_forbidden() {
public void missingRequiredPrivilege_forbidden() {
requestMetaDTO.setPrivileges(emptyList());
request.setPayload(null, requestMetaDTO);
......
......@@ -11,10 +11,7 @@ import org.springframework.stereotype.Component;
import java.util.Set;
import static ee.sm.ti.teis.cache.classifier.ClassifierItemCacheUpdateService.ClassifierItemCacheResponseDTO;
import static ee.sm.ti.teis.cache.classifier.ClassifierItemCacheUpdateService.ClassifierItemCreatedDTO;
import static ee.sm.ti.teis.cache.classifier.ClassifierItemCacheUpdateService.ClassifierItemReinitializeDTO;
import static ee.sm.ti.teis.cache.classifier.ClassifierItemCacheUpdateService.ClassifierItemUpdatedDTO;
import static ee.sm.ti.teis.cache.classifier.ClassifierItemCacheUpdateService.*;
@Component
@RequiredArgsConstructor
......@@ -29,14 +26,14 @@ public class DomainCacheConfig implements DomainCacheList {
classifierDefinitionCacheUpdateService);
}
@RabbitListener(queues = "#{@classifierItemCacheUpdateService.cacheResponseQueueName}")
@RabbitListener(queues = "#{@classifierItemCacheUpdateService.cacheResponseQueueName}", concurrency = "1")
public void classifierItemCacheResponseEvent(ClassifierItemCacheResponseDTO cacheResponseDTO) {
classifierItemCacheUpdateService.processSnapshot(cacheResponseDTO.getPayload(), cacheResponseDTO.getRequestMetaDTO());
classifierItemCacheUpdateService.processSnapshot(cacheResponseDTO.getPayload(), cacheResponseDTO.getRequestMetaDTO().getUserId());
}
@RabbitListener(queues = "#{@classifierDefinitionCacheUpdateService.cacheResponseQueueName}")
@RabbitListener(queues = "#{@classifierDefinitionCacheUpdateService.cacheResponseQueueName}", concurrency = "1")
public void classifierDefinitionCacheResponseEvent(ClassifierDefinitionCacheUpdateService.ClassifierDefinitionCacheResponseDTO cacheResponseDTO) {
classifierDefinitionCacheUpdateService.processSnapshot(cacheResponseDTO.getPayload(), cacheResponseDTO.getRequestMetaDTO());
classifierDefinitionCacheUpdateService.processSnapshot(cacheResponseDTO.getPayload(), cacheResponseDTO.getRequestMetaDTO().getUserId());
}
@RabbitListener(queues = "#{@classifierItemCacheUpdateService.createdEventsQueueName}")
......
package ee.sm.ti.teis.officials.config;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.cache.office.OfficeCacheUpdateService;
import ee.sm.ti.teis.cache.officials.OfficialUserCacheUpdateService;
import ee.sm.ti.teis.cache.officials.OfficialsGroupCacheUpdateService;
import ee.sm.ti.teis.configuration.QueueList;
import ee.sm.ti.teis.configuration.TeisQueue;
import ee.sm.ti.teis.domain.officials.*;
......@@ -15,6 +12,10 @@ import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List;
import static ee.sm.ti.teis.cache.office.OfficeCacheUpdateService.OfficesDomainCacheRequest;
import static ee.sm.ti.teis.cache.officials.OfficialUserCacheUpdateService.OfficialUsersDomainCacheRequest;
import static ee.sm.ti.teis.cache.officials.OfficialsGroupCacheUpdateService.OfficialsGroupsDomainCacheRequest;
@Configuration
public class QueueConfig implements QueueList {
public static final String GW_CREATE_OFFICIAL_USER_QUEUE = "officials-service.gw.createUserRequest";
......@@ -92,15 +93,15 @@ public class QueueConfig implements QueueList {
addMsQueue(queues, "msGetOfficialFromSequenceQueue", new GetOfficialFromSequenceRequest().routingKey(), MS_GET_OFFICIAL_FROM_SEQUENCE_QUEUE);
addCsQueue(queues, "csOfficialUsersQueue",
new OfficialUserCacheUpdateService.OfficialUsersDomainCacheRequest().routingKey(),
new OfficialUsersDomainCacheRequest().routingKey(),
CS_OFFICIAL_USERS_QUEUE);
addCsQueue(queues, "csOfficialsGroupsQueue",
new OfficialsGroupCacheUpdateService.OfficialsGroupsDomainCacheRequest().routingKey(),
new OfficialsGroupsDomainCacheRequest().routingKey(),
CS_OFFICIALS_GROUPS_QUEUE);
addCsQueue(queues, "csOfficesQueue",
new OfficeCacheUpdateService.OfficesDomainCacheRequest().routingKey(),
new OfficesDomainCacheRequest().routingKey(),
CS_OFFICES_QUEUE);
}
......
package ee.sm.ti.teis.officials.official.listener;
import ee.sm.ti.teis.domain.officials.OfficialUser;
import ee.sm.ti.teis.officials.config.QueueConfig;
import ee.sm.ti.teis.officials.official.OfficialUserEntity;
import ee.sm.ti.teis.officials.official.service.OfficialBusinessService;
import ee.sm.ti.teis.officials.official.service.OfficialComposeService;
import ee.sm.ti.teis.officials.official.service.OfficialDataService;
import lombok.RequiredArgsConstructor;
......@@ -15,17 +13,17 @@ import java.util.List;
import static ee.sm.ti.teis.cache.officials.OfficialUserCacheUpdateService.OfficialUserCacheResponseDTO;
import static ee.sm.ti.teis.cache.officials.OfficialUserCacheUpdateService.OfficialUsersDomainCacheRequest;
import static ee.sm.ti.teis.officials.config.QueueConfig.CS_OFFICIAL_USERS_QUEUE;
@Component
@RequiredArgsConstructor
public class OfficialCsListener {
private final OfficialBusinessService service;
private final RabbitTemplate csRabbitTemplate;
private final OfficialDataService dataService;
private final OfficialComposeService composeService;
@RabbitListener(queues = {QueueConfig.CS_OFFICIAL_USERS_QUEUE})
@RabbitListener(queues = {CS_OFFICIAL_USERS_QUEUE})
public void getOfficials(OfficialUsersDomainCacheRequest request) {
List<OfficialUserEntity> entities = dataService.getOfficialUsers();
List<OfficialUser> domains = composeService.composeDomains(entities);
......@@ -35,5 +33,4 @@ public class OfficialCsListener {
csRabbitTemplate.convertAndSend(response.routingKey(), response);
}
}
......@@ -43,7 +43,9 @@ management:
enabled: true
show-details: always
info.enabled: true
endpoints:
web:
exposure.include: health, info, prometheus, metrics
teis:
datasource:
packages-to-scan: ee.sm.ti.teis
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment