FINERACT-2452: New command processing - audit
Co-Authored-By: Adam Saghy <adam.saghy@dpc.hu> Co-Authored-By: Yu Wati Nyi <nyi22y@mtholyoke.edu>
This commit is contained in:
committed by
Aleksandar Vidakovic
co-authored by
Adam Saghy
Yu Wati Nyi
parent
1d1876edfd
commit
8d064ddf6c
+1
-8
@@ -24,14 +24,12 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.HeaderParam;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.command.core.CommandPipeline;
|
||||
@@ -41,7 +39,6 @@ import org.apache.fineract.infrastructure.businessdate.data.api.BusinessDateUpda
|
||||
import org.apache.fineract.infrastructure.businessdate.data.api.BusinessDateUpdateResponse;
|
||||
import org.apache.fineract.infrastructure.businessdate.mapper.BusinessDateMapper;
|
||||
import org.apache.fineract.infrastructure.businessdate.service.BusinessDateReadPlatformService;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@@ -75,14 +72,10 @@ public class BusinessDateApiResource {
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Operation(summary = "Update Business Date", description = "")
|
||||
public BusinessDateUpdateResponse updateBusinessDate(@HeaderParam("Idempotency-Key") String idempotencyKey,
|
||||
@Valid BusinessDateUpdateRequest request) {
|
||||
public BusinessDateUpdateResponse updateBusinessDate(@Valid BusinessDateUpdateRequest request) {
|
||||
|
||||
final BusinessDateUpdateCommand command = new BusinessDateUpdateCommand();
|
||||
|
||||
command.setId(UUID.randomUUID());
|
||||
command.setIdempotencyKey(idempotencyKey);
|
||||
command.setCreatedAt(DateUtils.getAuditOffsetDateTime());
|
||||
command.setPayload(request);
|
||||
|
||||
final Supplier<BusinessDateUpdateResponse> response = commandPipeline.send(command);
|
||||
|
||||
+8
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.businessdate.handler;
|
||||
|
||||
import io.github.resilience4j.retry.annotation.Retry;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.command.core.Command;
|
||||
@@ -38,6 +39,7 @@ public class BusinessDateUpdateHandler implements CommandHandler<BusinessDateUpd
|
||||
private final BusinessDateWritePlatformService businessDateWritePlatformService;
|
||||
private final BusinessDateMapper businessDateMapper;
|
||||
|
||||
@Retry(name = "commandBusinessDateUpdate", fallbackMethod = "fallback")
|
||||
@Transactional
|
||||
@Override
|
||||
public BusinessDateUpdateResponse handle(Command<BusinessDateUpdateRequest> command) {
|
||||
@@ -45,4 +47,10 @@ public class BusinessDateUpdateHandler implements CommandHandler<BusinessDateUpd
|
||||
businessDateDto = businessDateWritePlatformService.updateBusinessDate(businessDateDto);
|
||||
return businessDateMapper.mapUpdateResponse(businessDateDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BusinessDateUpdateResponse fallback(Command<BusinessDateUpdateRequest> command, Throwable t) {
|
||||
// NOTE: fallback method needs to be in the same class
|
||||
return CommandHandler.super.fallback(command, t);
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
-4
@@ -28,7 +28,6 @@ import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.command.core.CommandPipeline;
|
||||
@@ -37,7 +36,6 @@ import org.apache.fineract.infrastructure.cache.data.CacheData;
|
||||
import org.apache.fineract.infrastructure.cache.data.CacheSwitchRequest;
|
||||
import org.apache.fineract.infrastructure.cache.data.CacheSwitchResponse;
|
||||
import org.apache.fineract.infrastructure.cache.service.RuntimeDelegatingCacheManager;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -78,8 +76,6 @@ public class CacheApiResource {
|
||||
public CacheSwitchResponse switchCache(@Valid CacheSwitchRequest request) {
|
||||
final var command = new CacheSwitchCommand();
|
||||
|
||||
command.setId(UUID.randomUUID());
|
||||
command.setCreatedAt(DateUtils.getAuditOffsetDateTime());
|
||||
command.setPayload(request);
|
||||
|
||||
final Supplier<CacheSwitchResponse> response = commandPipeline.send(command);
|
||||
|
||||
+8
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.cache.handler;
|
||||
|
||||
import io.github.resilience4j.retry.annotation.Retry;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.command.core.Command;
|
||||
@@ -36,6 +37,7 @@ public class CacheSwitchCommandHandler implements CommandHandler<CacheSwitchRequ
|
||||
|
||||
private final CacheWritePlatformService cacheService;
|
||||
|
||||
@Retry(name = "commandCacheSwitch", fallbackMethod = "fallback")
|
||||
@Transactional
|
||||
@Override
|
||||
public CacheSwitchResponse handle(final Command<CacheSwitchRequest> command) {
|
||||
@@ -45,4 +47,10 @@ public class CacheSwitchCommandHandler implements CommandHandler<CacheSwitchRequ
|
||||
|
||||
return CacheSwitchResponse.builder().changes(changes).cacheType(request.getCacheType()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CacheSwitchResponse fallback(Command<CacheSwitchRequest> command, Throwable t) {
|
||||
// NOTE: fallback method needs to be in the same class
|
||||
return CommandHandler.super.fallback(command, t);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-7
@@ -23,16 +23,13 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.HeaderParam;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.command.core.CommandPipeline;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.infrastructure.event.external.command.ExternalConfigurationsUpdateCommand;
|
||||
import org.apache.fineract.infrastructure.event.external.data.ExternalEventConfigurationResponse;
|
||||
import org.apache.fineract.infrastructure.event.external.data.ExternalEventConfigurationUpdateRequest;
|
||||
@@ -61,13 +58,10 @@ public class ExternalEventConfigurationApiResource {
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Operation(summary = "Enable/Disable external events posting", description = "")
|
||||
public ExternalEventConfigurationUpdateResponse updateExternalEventConfigurations(@HeaderParam("Idempotency-Key") String idempotencyKey,
|
||||
public ExternalEventConfigurationUpdateResponse updateExternalEventConfigurations(
|
||||
@Valid ExternalEventConfigurationUpdateRequest request) {
|
||||
final var command = new ExternalConfigurationsUpdateCommand();
|
||||
|
||||
command.setId(UUID.randomUUID());
|
||||
command.setIdempotencyKey(idempotencyKey);
|
||||
command.setCreatedAt(DateUtils.getAuditOffsetDateTime());
|
||||
command.setPayload(request);
|
||||
|
||||
final Supplier<ExternalEventConfigurationUpdateResponse> response = commandPipeline.send(command);
|
||||
|
||||
+8
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.event.external.handler;
|
||||
|
||||
import io.github.resilience4j.retry.annotation.Retry;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.command.core.Command;
|
||||
@@ -36,9 +37,16 @@ public class ExternalEventConfigurationUpdateHandler
|
||||
|
||||
private final ExternalEventConfigurationWritePlatformService writePlatformService;
|
||||
|
||||
@Retry(name = "commandExternalEventConfigurationUpdate", fallbackMethod = "fallback")
|
||||
@Transactional
|
||||
@Override
|
||||
public ExternalEventConfigurationUpdateResponse handle(Command<ExternalEventConfigurationUpdateRequest> command) {
|
||||
return writePlatformService.updateConfigurations(command.getPayload());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalEventConfigurationUpdateResponse fallback(Command<ExternalEventConfigurationUpdateRequest> command, Throwable t) {
|
||||
// NOTE: fallback method needs to be in the same class
|
||||
return CommandHandler.super.fallback(command, t);
|
||||
}
|
||||
}
|
||||
|
||||
-4
@@ -27,11 +27,9 @@ import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.command.core.CommandPipeline;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.apache.fineract.organisation.monetary.command.CurrencyUpdateCommand;
|
||||
import org.apache.fineract.organisation.monetary.data.CurrencyConfigurationData;
|
||||
import org.apache.fineract.organisation.monetary.data.CurrencyUpdateRequest;
|
||||
@@ -70,8 +68,6 @@ public class CurrenciesApiResource {
|
||||
public CurrencyUpdateResponse updateCurrencies(@Valid CurrencyUpdateRequest request) {
|
||||
final var command = new CurrencyUpdateCommand();
|
||||
|
||||
command.setId(UUID.randomUUID());
|
||||
command.setCreatedAt(DateUtils.getAuditOffsetDateTime());
|
||||
command.setPayload(request);
|
||||
|
||||
final Supplier<CurrencyUpdateResponse> response = commandPipeline.send(command);
|
||||
|
||||
+9
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.fineract.organisation.monetary.handler;
|
||||
|
||||
import io.github.resilience4j.retry.annotation.Retry;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.fineract.command.core.Command;
|
||||
@@ -35,9 +36,17 @@ public class CurrencyUpdateCommandHandler implements CommandHandler<CurrencyUpda
|
||||
|
||||
private final CurrencyWritePlatformService writePlatformService;
|
||||
|
||||
@Retry(name = "commandCurrencyUpdate", fallbackMethod = "fallback")
|
||||
@Transactional
|
||||
@Override
|
||||
public CurrencyUpdateResponse handle(final Command<CurrencyUpdateRequest> command) {
|
||||
// NOTE: fallback method needs to be in the same class
|
||||
return writePlatformService.updateAllowedCurrencies(command.getPayload());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CurrencyUpdateResponse fallback(Command<CurrencyUpdateRequest> command, Throwable t) {
|
||||
// NOTE: fallback method needs to be in the same class
|
||||
return CommandHandler.super.fallback(command, t);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user