Merge branch 'dmp-refactoring' of code-repo.d4science.org:MaDgiK-CITE/argos into dmp-refactoring
# Conflicts: # dmp-backend/core/src/main/java/eu/eudat/integrationevent/outbox/tenanttouched/TenantTouchedIntegrationEventHandlerImpl.java
This commit is contained in:
commit
c1a3ac89d6
|
@ -145,6 +145,8 @@ public class AuditableAction {
|
||||||
|
|
||||||
public static final EventId Maintenance_GenerateElastic = new EventId(220000, "Maintenance_GenerateElastic");
|
public static final EventId Maintenance_GenerateElastic = new EventId(220000, "Maintenance_GenerateElastic");
|
||||||
public static final EventId Maintenance_ClearElastic = new EventId(230000, "Maintenance_ClearElastic");
|
public static final EventId Maintenance_ClearElastic = new EventId(230000, "Maintenance_ClearElastic");
|
||||||
|
public static final EventId Maintenance_SendUserTouchEvents = new EventId(230001, "Maintenance_SendUserTouchEvents");
|
||||||
|
public static final EventId Maintenance_SendTenantTouchEvents = new EventId(230002, "Maintenance_SendTenantTouchEvents");
|
||||||
|
|
||||||
public static final EventId Principal_Lookup = new EventId(240000, "Principal_Lookup");
|
public static final EventId Principal_Lookup = new EventId(240000, "Principal_Lookup");
|
||||||
public static final EventId Principal_MyTenants = new EventId(240001, "Principal_MyTenants");
|
public static final EventId Principal_MyTenants = new EventId(240001, "Principal_MyTenants");
|
||||||
|
|
|
@ -22,6 +22,8 @@ public final class Permission {
|
||||||
public static String PublicBrowseReferenceType = "PublicBrowseReferenceType";
|
public static String PublicBrowseReferenceType = "PublicBrowseReferenceType";
|
||||||
//Elastic
|
//Elastic
|
||||||
public static String ManageElastic = "ManageElastic";
|
public static String ManageElastic = "ManageElastic";
|
||||||
|
//Queue Events
|
||||||
|
public static String ManageQueueEvents = "ManageQueueEvents";
|
||||||
|
|
||||||
|
|
||||||
//Deposit
|
//Deposit
|
||||||
|
|
|
@ -8,9 +8,10 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Component
|
@Component("outboxtenanttouchedintegrationeventhandler")
|
||||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
public class TenantTouchedIntegrationEventHandlerImpl implements TenantTouchedIntegrationEventHandler {
|
public class TenantTouchedIntegrationEventHandlerImpl implements TenantTouchedIntegrationEventHandler {
|
||||||
|
|
||||||
private final OutboxService outboxService;
|
private final OutboxService outboxService;
|
||||||
|
|
||||||
public TenantTouchedIntegrationEventHandlerImpl(OutboxService outboxService) {
|
public TenantTouchedIntegrationEventHandlerImpl(OutboxService outboxService) {
|
||||||
|
|
|
@ -2,33 +2,68 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.audit.AuditableAction;
|
import eu.eudat.audit.AuditableAction;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.TenantEntity;
|
||||||
|
import eu.eudat.data.TenantEntityManager;
|
||||||
|
import eu.eudat.data.UserEntity;
|
||||||
|
import eu.eudat.integrationevent.outbox.tenanttouched.TenantTouchedIntegrationEvent;
|
||||||
|
import eu.eudat.integrationevent.outbox.tenanttouched.TenantTouchedIntegrationEventHandler;
|
||||||
|
import eu.eudat.integrationevent.outbox.usertouched.UserTouchedIntegrationEventHandler;
|
||||||
|
import eu.eudat.query.TenantQuery;
|
||||||
|
import eu.eudat.query.UserQuery;
|
||||||
import eu.eudat.service.elastic.ElasticService;
|
import eu.eudat.service.elastic.ElasticService;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.auditing.AuditService;
|
import gr.cite.tools.auditing.AuditService;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.management.InvalidApplicationException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(path = "api/maintenance")
|
@RequestMapping(path = "api/maintenance")
|
||||||
public class MaintenanceController {
|
public class MaintenanceController {
|
||||||
|
|
||||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(MaintenanceController.class));
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(MaintenanceController.class));
|
||||||
|
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
|
|
||||||
private final ElasticService elasticService;
|
private final ElasticService elasticService;
|
||||||
|
|
||||||
private final AuditService auditService;
|
private final AuditService auditService;
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
private final TenantEntityManager entityManager;
|
||||||
|
|
||||||
|
private final UserTouchedIntegrationEventHandler userTouchedIntegrationEventHandler;
|
||||||
|
|
||||||
|
private final TenantTouchedIntegrationEventHandler tenantTouchedIntegrationEventHandler;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public MaintenanceController(AuthorizationService authorizationService, ElasticService elasticService, AuditService auditService) {
|
public MaintenanceController(
|
||||||
|
AuthorizationService authorizationService,
|
||||||
|
ElasticService elasticService,
|
||||||
|
AuditService auditService,
|
||||||
|
QueryFactory queryFactory,
|
||||||
|
TenantEntityManager entityManager,
|
||||||
|
UserTouchedIntegrationEventHandler userTouchedIntegrationEventHandler,
|
||||||
|
TenantTouchedIntegrationEventHandler tenantTouchedIntegrationEventHandler) {
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
this.elasticService = elasticService;
|
this.elasticService = elasticService;
|
||||||
this.auditService = auditService;
|
this.auditService = auditService;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.entityManager = entityManager;
|
||||||
|
this.userTouchedIntegrationEventHandler = userTouchedIntegrationEventHandler;
|
||||||
|
this.tenantTouchedIntegrationEventHandler = tenantTouchedIntegrationEventHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/index/elastic"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/index/elastic"})
|
||||||
public void generateIndex() throws Exception {
|
public void generateIndex() throws Exception {
|
||||||
logger.debug("generate elastic ");
|
logger.debug("generate elastic ");
|
||||||
|
@ -36,6 +71,7 @@ public class MaintenanceController {
|
||||||
|
|
||||||
elasticService.resetDmpIndex();
|
elasticService.resetDmpIndex();
|
||||||
elasticService.resetDescriptionIndex();
|
elasticService.resetDescriptionIndex();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Maintenance_GenerateElastic);
|
this.auditService.track(AuditableAction.Maintenance_GenerateElastic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +82,43 @@ public class MaintenanceController {
|
||||||
|
|
||||||
elasticService.deleteDescriptionIndex();
|
elasticService.deleteDescriptionIndex();
|
||||||
elasticService.deleteDmpIndex();
|
elasticService.deleteDmpIndex();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Maintenance_ClearElastic);
|
this.auditService.track(AuditableAction.Maintenance_ClearElastic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.DELETE, value = {"/events/users/touch"})
|
||||||
|
public void sendUserTouchEvents() throws InvalidApplicationException {
|
||||||
|
logger.debug("send user touch queue events");
|
||||||
|
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
|
||||||
|
|
||||||
|
this.entityManager.disableTenantFilters();
|
||||||
|
UserQuery userQuery = queryFactory.query(UserQuery.class).isActive(IsActive.Active);
|
||||||
|
List<UserEntity> users = userQuery.collect();
|
||||||
|
this.entityManager.enableTenantFilters();
|
||||||
|
|
||||||
|
for(UserEntity user : users)
|
||||||
|
this.userTouchedIntegrationEventHandler.handle(user.getId());
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.Maintenance_SendUserTouchEvents);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.DELETE, value = {"/events/tenants/touch"})
|
||||||
|
public void sendTenantTouchEvents() throws InvalidApplicationException {
|
||||||
|
logger.debug("send tenant touch queue events");
|
||||||
|
this.authorizationService.authorizeForce(Permission.ManageQueueEvents);
|
||||||
|
|
||||||
|
this.entityManager.disableTenantFilters();
|
||||||
|
TenantQuery tenantQuery = queryFactory.query(TenantQuery.class).isActive(IsActive.Active);
|
||||||
|
List<TenantEntity> tenants = tenantQuery.collect();
|
||||||
|
this.entityManager.enableTenantFilters();
|
||||||
|
|
||||||
|
for (TenantEntity tenant : tenants) {
|
||||||
|
TenantTouchedIntegrationEvent event = new TenantTouchedIntegrationEvent();
|
||||||
|
event.setId(tenant.getId());
|
||||||
|
event.setCode(tenant.getCode());
|
||||||
|
this.tenantTouchedIntegrationEventHandler.handle(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.auditService.track(AuditableAction.Maintenance_SendTenantTouchEvents);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,14 @@ permissions:
|
||||||
allowAnonymous: false
|
allowAnonymous: false
|
||||||
allowAuthenticated: false
|
allowAuthenticated: false
|
||||||
|
|
||||||
|
# Queue Events
|
||||||
|
ManageQueueEvents:
|
||||||
|
roles:
|
||||||
|
- Admin
|
||||||
|
clients: [ ]
|
||||||
|
allowAnonymous: false
|
||||||
|
allowAuthenticated: false
|
||||||
|
|
||||||
# Deposit
|
# Deposit
|
||||||
BrowseDeposit:
|
BrowseDeposit:
|
||||||
roles:
|
roles:
|
||||||
|
|
Loading…
Reference in New Issue