Skip to content

Commit

Permalink
MODTLR-98 Remove redundant changes
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrVidinieiev committed Dec 9, 2024
1 parent 311c681 commit 565b4d9
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 273 deletions.
29 changes: 5 additions & 24 deletions src/main/java/org/folio/listener/kafka/KafkaEventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
import java.nio.charset.StandardCharsets;
import java.util.Optional;

import org.folio.domain.dto.Loan;
import org.folio.domain.dto.Request;
import org.folio.domain.dto.RequestsBatchUpdate;
import org.folio.domain.dto.User;
import org.folio.domain.dto.UserGroup;
import org.folio.exception.KafkaEventDeserializationException;
import org.folio.service.KafkaEventHandler;
import org.folio.service.impl.LoanEventHandler;
import org.folio.service.impl.RequestBatchUpdateEventHandler;
import org.folio.service.impl.RequestEventHandler;
import org.folio.service.impl.UserEventHandler;
Expand All @@ -36,22 +34,18 @@
public class KafkaEventListener {
private static final ObjectMapper objectMapper = new ObjectMapper();
private final RequestEventHandler requestEventHandler;
private final LoanEventHandler loanEventHandler;
private final UserGroupEventHandler userGroupEventHandler;
private final UserEventHandler userEventHandler;
private final SystemUserScopedExecutionService systemUserScopedExecutionService;
private final RequestBatchUpdateEventHandler requestBatchEventHandler;

@Autowired
public KafkaEventListener(RequestEventHandler requestEventHandler,
LoanEventHandler loanEventHandler,
RequestBatchUpdateEventHandler requestBatchEventHandler,
SystemUserScopedExecutionService systemUserScopedExecutionService,
UserGroupEventHandler userGroupEventHandler,
UserEventHandler userEventHandler) {
public KafkaEventListener(@Autowired RequestEventHandler requestEventHandler,
@Autowired RequestBatchUpdateEventHandler requestBatchEventHandler,
@Autowired SystemUserScopedExecutionService systemUserScopedExecutionService,
@Autowired UserGroupEventHandler userGroupEventHandler,
@Autowired UserEventHandler userEventHandler) {

this.requestEventHandler = requestEventHandler;
this.loanEventHandler = loanEventHandler;
this.systemUserScopedExecutionService = systemUserScopedExecutionService;
this.userGroupEventHandler = userGroupEventHandler;
this.requestBatchEventHandler = requestBatchEventHandler;
Expand Down Expand Up @@ -82,19 +76,6 @@ public void handleRequestBatchUpdateEvent(String eventString, MessageHeaders mes
log.info("handleRequestBatchUpdateEvent:: event consumed: {}", event::getId);
}

@KafkaListener(
topicPattern = "${folio.environment}\\.\\w+\\.circulation\\.loan",
groupId = "${spring.kafka.consumer.group-id}"
)
public void handleLoanEvent(String eventString, MessageHeaders messageHeaders) {
log.debug("handleLoanEvent:: event: {}", () -> eventString);
KafkaEvent<Loan> event = deserialize(eventString, messageHeaders, Loan.class);
log.info("handleLoanEvent:: event received: {}", event::getId);
log.info("handleLoanEvent:: event: {}", eventString);
handleEvent(event, loanEventHandler);
log.info("handleLoanEvent:: event consumed: {}", event::getId);
}

private <T> void handleEvent(KafkaEvent<T> event, KafkaEventHandler<T> handler) {
try {
systemUserScopedExecutionService.executeAsyncSystemUserScoped(CENTRAL_TENANT_ID,
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/org/folio/service/ConsortiaService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
import org.folio.domain.dto.TenantCollection;

public interface ConsortiaService {
TenantCollection getAllDataTenants(String consortiumId);

// boolean isCurrentTenantCentral();

// <T> T executeInTenant(String tenantId, Callable<T> action);
TenantCollection getAllConsortiumTenants(String consortiumId);
Collection<Tenant> getAllConsortiumTenants();
}
1 change: 0 additions & 1 deletion src/main/java/org/folio/service/UserTenantsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

public interface UserTenantsService {
UserTenant findFirstUserTenant();

String getCentralTenantId();
}
35 changes: 0 additions & 35 deletions src/main/java/org/folio/service/impl/ConsortiaServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.folio.domain.dto.UserTenant;
import org.folio.service.ConsortiaService;
import org.folio.service.UserTenantsService;
import org.folio.spring.service.SystemUserScopedExecutionService;
import org.springframework.stereotype.Service;

import lombok.RequiredArgsConstructor;
Expand All @@ -24,11 +23,6 @@ public class ConsortiaServiceImpl implements ConsortiaService {
private final ConsortiaClient consortiaClient;
private final UserTenantsService userTenantsService;

@Override
public TenantCollection getAllDataTenants(String consortiumId) {
return consortiaClient.getConsortiaTenants(consortiumId);
}

@Override
public TenantCollection getAllConsortiumTenants(String consortiumId) {
return consortiaClient.getConsortiaTenants(consortiumId);
Expand All @@ -46,33 +40,4 @@ public Collection<Tenant> getAllConsortiumTenants() {
log.info("getAllConsortiumTenants:: found {} consortium tenants", tenants::size);
return tenants;
}

// @Override
// public boolean isCurrentTenantCentral() {
// var userTenant = userTenantsService.findFirstUserTenant();
// var centralTenantId = userTenant.getCentralTenantId();
// var currentTenantId = userTenant.getTenantId();
//
// if (centralTenantId == null || currentTenantId == null) {
// log.warn("isCurrentTenantCentral:: Cannot determine central tenant or current tenant");
// return false;
// }
//
// return centralTenantId.equals(currentTenantId);
// }
//
// @Override
// public <T> T executeInTenant(String tenantId, Callable<T> action) {
// if (isCurrentTenantCentral()) {
// try {
// return action.call();
// } catch (Exception e) {
// log.info("executeInTenant:: Failed to execute in Central tenant");
// return null;
// }
// } else {
// return systemUserScopedExecutionService.executeSystemUserScoped(
// tenantId, action);
// }
// }
}
40 changes: 0 additions & 40 deletions src/main/java/org/folio/service/impl/LoanEventHandler.java

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/resources/swagger.api/ecs-tlr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ components:
$ref: 'schemas/request.json'
requests:
$ref: 'schemas/requests.json'
loan:
$ref: 'schemas/loan.json'
searchInstancesResponse:
$ref: 'schemas/search/searchInstancesResponse.yaml'
searchItemResponse:
Expand Down
166 changes: 0 additions & 166 deletions src/main/resources/swagger.api/schemas/loan.json

This file was deleted.

0 comments on commit 565b4d9

Please sign in to comment.