tenant fixes
This commit is contained in:
parent
fa6d100b41
commit
f156d79ace
|
@ -9,9 +9,9 @@ import gr.cite.annotation.integrationevent.TrackedEvent;
|
|||
import gr.cite.annotation.integrationevent.inbox.annotationentitiesremoval.AnnotationEntitiesRemovalIntegrationEventHandler;
|
||||
import gr.cite.annotation.integrationevent.inbox.annotationentitiestouch.AnnotationEntitiesTouchedIntegrationEventHandler;
|
||||
import gr.cite.annotation.integrationevent.inbox.tenantremoval.TenantRemovalIntegrationEventHandler;
|
||||
import gr.cite.annotation.integrationevent.inbox.tenanttouch.TenantTouchedIntegrationEventHandler;
|
||||
import gr.cite.annotation.integrationevent.inbox.tenanttouched.TenantTouchedIntegrationEventHandler;
|
||||
import gr.cite.annotation.integrationevent.inbox.userremoval.UserRemovalIntegrationEventHandler;
|
||||
import gr.cite.annotation.integrationevent.inbox.usertouch.UserTouchedIntegrationEventHandler;
|
||||
import gr.cite.annotation.integrationevent.inbox.usertouched.UserTouchedIntegrationEventHandler;
|
||||
import gr.cite.annotation.query.QueueInboxQuery;
|
||||
import gr.cite.queueinbox.entity.QueueInbox;
|
||||
import gr.cite.queueinbox.entity.QueueInboxStatus;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package gr.cite.annotation.integrationevent.inbox.tenantremoval;
|
||||
|
||||
|
||||
import gr.cite.annotation.integrationevent.inbox.IntegrationEventHandler;
|
||||
|
||||
public interface TenantRemovalIntegrationEventHandler extends IntegrationEventHandler {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package gr.cite.annotation.integrationevent.inbox.tenantremoval;
|
||||
|
||||
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
||||
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractorProperties;
|
||||
import gr.cite.annotation.audit.AuditableAction;
|
||||
import gr.cite.annotation.common.JsonHandlingService;
|
||||
import gr.cite.annotation.data.TenantEntityManager;
|
||||
|
@ -7,8 +9,6 @@ import gr.cite.annotation.integrationevent.inbox.EventProcessingStatus;
|
|||
import gr.cite.annotation.integrationevent.inbox.InboxPrincipal;
|
||||
import gr.cite.annotation.integrationevent.inbox.IntegrationEventProperties;
|
||||
import gr.cite.annotation.service.tenant.TenantService;
|
||||
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
||||
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractorProperties;
|
||||
import gr.cite.tools.auditing.AuditService;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -34,12 +34,12 @@ public class TenantRemovalIntegrationEventHandlerImpl implements TenantRemovalIn
|
|||
private final TenantRemovalConsistencyHandler tenantRemovalConsistencyHandler;
|
||||
public TenantRemovalIntegrationEventHandlerImpl(JsonHandlingService jsonHandlingService, CurrentPrincipalResolver currentPrincipalResolver, ClaimExtractorProperties claimExtractorProperties, TenantService tenantService, AuditService auditService, TenantEntityManager tenantEntityManager, TenantRemovalConsistencyHandler tenantRemovalConsistencyHandler) {
|
||||
this.jsonHandlingService = jsonHandlingService;
|
||||
this.currentPrincipalResolver = currentPrincipalResolver;
|
||||
this.claimExtractorProperties = claimExtractorProperties;
|
||||
this.tenantService = tenantService;
|
||||
this.auditService = auditService;
|
||||
this.tenantEntityManager = tenantEntityManager;
|
||||
this.tenantRemovalConsistencyHandler = tenantRemovalConsistencyHandler;
|
||||
this.currentPrincipalResolver = currentPrincipalResolver;
|
||||
this.claimExtractorProperties = claimExtractorProperties;
|
||||
this.tenantService = tenantService;
|
||||
this.auditService = auditService;
|
||||
this.tenantEntityManager = tenantEntityManager;
|
||||
this.tenantRemovalConsistencyHandler = tenantRemovalConsistencyHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package gr.cite.annotation.integrationevent.inbox.tenanttouch;
|
||||
package gr.cite.annotation.integrationevent.inbox.tenanttouched;
|
||||
|
||||
|
||||
import gr.cite.annotation.integrationevent.TrackedEvent;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package gr.cite.annotation.integrationevent.inbox.tenanttouch;
|
||||
package gr.cite.annotation.integrationevent.inbox.tenanttouched;
|
||||
|
||||
import gr.cite.annotation.integrationevent.inbox.IntegrationEventHandler;
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package gr.cite.annotation.integrationevent.inbox.tenanttouch;
|
||||
package gr.cite.annotation.integrationevent.inbox.tenanttouched;
|
||||
|
||||
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
||||
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractorProperties;
|
||||
import gr.cite.annotation.audit.AuditableAction;
|
||||
import gr.cite.annotation.common.JsonHandlingService;
|
||||
import gr.cite.annotation.data.TenantEntityManager;
|
||||
|
@ -8,8 +10,6 @@ import gr.cite.annotation.integrationevent.inbox.InboxPrincipal;
|
|||
import gr.cite.annotation.integrationevent.inbox.IntegrationEventProperties;
|
||||
import gr.cite.annotation.model.persist.TenantTouchedIntegrationEventPersist;
|
||||
import gr.cite.annotation.service.tenant.TenantService;
|
||||
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
||||
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractorProperties;
|
||||
import gr.cite.tools.auditing.AuditService;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
|
@ -1,5 +1,6 @@
|
|||
package gr.cite.annotation.integrationevent.inbox.userremoval;
|
||||
|
||||
|
||||
import gr.cite.annotation.integrationevent.inbox.ConsistencyPredicates;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package gr.cite.annotation.integrationevent.inbox.userremoval;
|
||||
|
||||
|
||||
import gr.cite.annotation.integrationevent.inbox.IntegrationEventHandler;
|
||||
|
||||
public interface UserRemovalIntegrationEventHandler extends IntegrationEventHandler {
|
||||
|
|
|
@ -1,23 +1,18 @@
|
|||
package gr.cite.annotation.integrationevent.inbox.userremoval;
|
||||
|
||||
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
||||
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractorProperties;
|
||||
import gr.cite.annotation.audit.AuditableAction;
|
||||
import gr.cite.annotation.common.JsonHandlingService;
|
||||
import gr.cite.annotation.common.scope.tenant.TenantScope;
|
||||
import gr.cite.annotation.data.TenantEntity;
|
||||
import gr.cite.annotation.data.TenantEntityManager;
|
||||
import gr.cite.annotation.errorcode.ErrorThesaurusProperties;
|
||||
import gr.cite.annotation.integrationevent.inbox.EventProcessingStatus;
|
||||
import gr.cite.annotation.integrationevent.inbox.InboxPrincipal;
|
||||
import gr.cite.annotation.integrationevent.inbox.IntegrationEventProperties;
|
||||
import gr.cite.annotation.model.Tenant;
|
||||
import gr.cite.annotation.query.TenantQuery;
|
||||
import gr.cite.annotation.service.user.UserService;
|
||||
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
||||
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractorProperties;
|
||||
import gr.cite.tools.auditing.AuditService;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyValidationException;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
|
@ -26,7 +21,6 @@ import org.springframework.context.annotation.Scope;
|
|||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -42,7 +36,6 @@ public class UserRemovalIntegrationEventHandlerImpl implements UserRemovalIntegr
|
|||
private final ErrorThesaurusProperties errors;
|
||||
|
||||
private final MessageSource messageSource;
|
||||
private final QueryFactory queryFactory;
|
||||
private final TenantScope tenantScope;
|
||||
private final CurrentPrincipalResolver currentPrincipalResolver;
|
||||
private final ClaimExtractorProperties claimExtractorProperties;
|
||||
|
@ -52,21 +45,20 @@ public class UserRemovalIntegrationEventHandlerImpl implements UserRemovalIntegr
|
|||
private final TenantEntityManager tenantEntityManager;
|
||||
|
||||
public UserRemovalIntegrationEventHandlerImpl(
|
||||
JsonHandlingService jsonHandlingService,
|
||||
ErrorThesaurusProperties errors,
|
||||
MessageSource messageSource, QueryFactory queryFactory, TenantScope tenantScope, CurrentPrincipalResolver currentPrincipalResolver, ClaimExtractorProperties claimExtractorProperties, UserRemovalConsistencyHandler userRemovalConsistencyHandler, UserService userService, AuditService auditService, TenantEntityManager tenantEntityManager
|
||||
JsonHandlingService jsonHandlingService,
|
||||
ErrorThesaurusProperties errors,
|
||||
MessageSource messageSource, TenantScope tenantScope, CurrentPrincipalResolver currentPrincipalResolver, ClaimExtractorProperties claimExtractorProperties, UserRemovalConsistencyHandler userRemovalConsistencyHandler, UserService userService, AuditService auditService, TenantEntityManager tenantEntityManager
|
||||
) {
|
||||
this.jsonHandlingService = jsonHandlingService;
|
||||
this.errors = errors;
|
||||
this.messageSource = messageSource;
|
||||
this.queryFactory = queryFactory;
|
||||
this.tenantScope = tenantScope;
|
||||
this.currentPrincipalResolver = currentPrincipalResolver;
|
||||
this.claimExtractorProperties = claimExtractorProperties;
|
||||
this.userRemovalConsistencyHandler = userRemovalConsistencyHandler;
|
||||
this.userService = userService;
|
||||
this.auditService = auditService;
|
||||
this.tenantEntityManager = tenantEntityManager;
|
||||
this.tenantScope = tenantScope;
|
||||
this.currentPrincipalResolver = currentPrincipalResolver;
|
||||
this.claimExtractorProperties = claimExtractorProperties;
|
||||
this.userRemovalConsistencyHandler = userRemovalConsistencyHandler;
|
||||
this.userService = userService;
|
||||
this.auditService = auditService;
|
||||
this.tenantEntityManager = tenantEntityManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,29 +73,21 @@ public class UserRemovalIntegrationEventHandlerImpl implements UserRemovalIntegr
|
|||
|
||||
EventProcessingStatus status = EventProcessingStatus.Success;
|
||||
try {
|
||||
if (this.tenantScope.isMultitenant() && properties.getTenantId() != null) {
|
||||
TenantEntity tenant = queryFactory.query(TenantQuery.class).disableTracking().ids(properties.getTenantId()).firstAs(new BaseFieldSet().ensure(Tenant._id).ensure(Tenant._code));
|
||||
if (tenant == null) {
|
||||
logger.error("missing tenant from event message");
|
||||
return EventProcessingStatus.Error;
|
||||
}
|
||||
this.tenantScope.setTempTenant(tenantEntityManager, properties.getTenantId(), tenant.getCode());
|
||||
} else if (this.tenantScope.isMultitenant()) {
|
||||
// logger.error("missing tenant from event message");
|
||||
// return EventProcessingStatus.Error;
|
||||
this.tenantScope.setTempTenant(tenantEntityManager, null, this.tenantScope.getDefaultTenantCode());
|
||||
}
|
||||
|
||||
currentPrincipalResolver.push(InboxPrincipal.build(properties, claimExtractorProperties));
|
||||
|
||||
if (!(userRemovalConsistencyHandler.isConsistent(new UserRemovalConsistencyPredicates(event.getUserId())))) {
|
||||
status = EventProcessingStatus.Postponed;
|
||||
currentPrincipalResolver.pop();
|
||||
tenantScope.removeTempTenant(this.tenantEntityManager);
|
||||
return status;
|
||||
}
|
||||
try{
|
||||
this.tenantEntityManager.disableTenantFilters();
|
||||
if (!(userRemovalConsistencyHandler.isConsistent(new UserRemovalConsistencyPredicates(event.getUserId())))) {
|
||||
status = EventProcessingStatus.Postponed;
|
||||
currentPrincipalResolver.pop();
|
||||
tenantScope.removeTempTenant(this.tenantEntityManager);
|
||||
return status;
|
||||
}
|
||||
|
||||
userService.deleteAndSave(event.getUserId());
|
||||
userService.deleteAndSave(event.getUserId());
|
||||
} finally {
|
||||
this.tenantEntityManager.reloadTenantFilters();
|
||||
}
|
||||
|
||||
auditService.track(AuditableAction.User_Delete, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("id", event.getUserId())
|
||||
|
@ -114,11 +98,6 @@ public class UserRemovalIntegrationEventHandlerImpl implements UserRemovalIntegr
|
|||
logger.error("Problem getting list of queue outbox. Skipping: {}", ex.getMessage(), ex);
|
||||
} finally {
|
||||
currentPrincipalResolver.pop();
|
||||
try {
|
||||
tenantScope.removeTempTenant(this.tenantEntityManager);
|
||||
} catch (InvalidApplicationException e) {
|
||||
logger.error( e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package gr.cite.annotation.integrationevent.inbox.usertouch;
|
||||
package gr.cite.annotation.integrationevent.inbox.usertouched;
|
||||
|
||||
import gr.cite.annotation.common.enums.ContactInfoType;
|
||||
import gr.cite.annotation.common.validation.BaseValidator;
|
||||
import gr.cite.annotation.convention.ConventionService;
|
||||
import gr.cite.annotation.errorcode.ErrorThesaurusProperties;
|
||||
import gr.cite.annotation.integrationevent.TrackedEvent;
|
||||
import gr.cite.annotation.model.persist.UserTouchedIntegrationEventPersist;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
|
@ -162,7 +161,7 @@ public class UserTouchedIntegrationEvent extends TrackedEvent {
|
|||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
@Component(UserTouchedIntegrationEvent.UserContactInfo.UserTouchedIntegrationUserContactInfoEventValidator.ValidatorName)
|
||||
@Component(UserTouchedIntegrationUserContactInfoEventValidator.ValidatorName)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public static class UserTouchedIntegrationUserContactInfoEventValidator extends BaseValidator<UserContactInfo> {
|
||||
|
||||
|
@ -211,7 +210,7 @@ public class UserTouchedIntegrationEvent extends TrackedEvent {
|
|||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
@Component(UserCredential.UserTouchedIntegrationUserCredentialEventValidator.ValidatorName)
|
||||
@Component(UserTouchedIntegrationUserCredentialEventValidator.ValidatorName)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public static class UserTouchedIntegrationUserCredentialEventValidator extends BaseValidator<UserCredential> {
|
||||
|
||||
|
@ -253,7 +252,7 @@ public class UserTouchedIntegrationEvent extends TrackedEvent {
|
|||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
@Component(TenantUser.UserTouchedIntegrationTenantUserEventValidator.ValidatorName)
|
||||
@Component(UserTouchedIntegrationTenantUserEventValidator.ValidatorName)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public static class UserTouchedIntegrationTenantUserEventValidator extends BaseValidator<TenantUser> {
|
||||
|
||||
|
@ -282,7 +281,7 @@ public class UserTouchedIntegrationEvent extends TrackedEvent {
|
|||
}
|
||||
}
|
||||
|
||||
@Component(UserTouchedIntegrationEvent.UserTouchedIntegrationEventValidator.ValidatorName)
|
||||
@Component(UserTouchedIntegrationEventValidator.ValidatorName)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public static class UserTouchedIntegrationEventValidator extends BaseValidator<UserTouchedIntegrationEvent> {
|
||||
|
||||
|
@ -315,7 +314,7 @@ public class UserTouchedIntegrationEvent extends TrackedEvent {
|
|||
.failOn(UserTouchedIntegrationEvent._name).failWith(messageSource.getMessage("Validation_Required", new Object[]{UserTouchedIntegrationEvent._name}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(() -> !this.isEmpty(item.getName()))
|
||||
.must(() -> this.lessEqualLength(item.getName(), UserTouchedIntegrationEventPersist._nameLength))
|
||||
.must(() -> this.lessEqualLength(item.getName(), UserTouchedIntegrationEvent._nameLength))
|
||||
.failOn(UserTouchedIntegrationEvent._name).failWith(messageSource.getMessage("Validation_MaxLength", new Object[]{UserTouchedIntegrationEvent._name}, LocaleContextHolder.getLocale())),
|
||||
this.navSpec()
|
||||
.iff(() -> !this.isListNullOrEmpty(item.getUserContactInfo()))
|
|
@ -1,4 +1,5 @@
|
|||
package gr.cite.annotation.integrationevent.inbox.usertouch;
|
||||
package gr.cite.annotation.integrationevent.inbox.usertouched;
|
||||
|
||||
|
||||
import gr.cite.annotation.integrationevent.inbox.IntegrationEventHandler;
|
||||
|
|
@ -1,21 +1,17 @@
|
|||
package gr.cite.annotation.integrationevent.inbox.usertouch;
|
||||
package gr.cite.annotation.integrationevent.inbox.usertouched;
|
||||
|
||||
import gr.cite.annotation.data.TenantEntityManager;
|
||||
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
||||
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractorProperties;
|
||||
import gr.cite.annotation.audit.AuditableAction;
|
||||
import gr.cite.annotation.common.JsonHandlingService;
|
||||
import gr.cite.annotation.common.scope.tenant.TenantScope;
|
||||
import gr.cite.annotation.data.TenantEntity;
|
||||
import gr.cite.annotation.data.TenantEntityManager;
|
||||
import gr.cite.annotation.integrationevent.inbox.EventProcessingStatus;
|
||||
import gr.cite.annotation.integrationevent.inbox.InboxPrincipal;
|
||||
import gr.cite.annotation.integrationevent.inbox.IntegrationEventProperties;
|
||||
import gr.cite.annotation.model.Tenant;
|
||||
import gr.cite.annotation.query.TenantQuery;
|
||||
import gr.cite.annotation.service.user.UserService;
|
||||
import gr.cite.commons.web.oidc.principal.extractor.ClaimExtractorProperties;
|
||||
import gr.cite.tools.auditing.AuditService;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.validation.ValidatorFactory;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -23,7 +19,6 @@ import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -46,17 +41,17 @@ public class UserTouchedIntegrationEventHandlerImpl implements UserTouchedIntegr
|
|||
private final TenantEntityManager tenantEntityManager;
|
||||
|
||||
public UserTouchedIntegrationEventHandlerImpl(
|
||||
JsonHandlingService jsonHandlingService,
|
||||
ValidatorFactory validatorFactory, QueryFactory queryFactory, TenantScope tenantScope, CurrentPrincipalResolver currentPrincipalResolver, ClaimExtractorProperties claimExtractorProperties, UserService userService, AuditService auditService, TenantEntityManager tenantEntityManager) {
|
||||
JsonHandlingService jsonHandlingService,
|
||||
ValidatorFactory validatorFactory, QueryFactory queryFactory, TenantScope tenantScope, CurrentPrincipalResolver currentPrincipalResolver, ClaimExtractorProperties claimExtractorProperties, UserService userService, AuditService auditService, TenantEntityManager tenantEntityManager) {
|
||||
this.jsonHandlingService = jsonHandlingService;
|
||||
this.validatorFactory = validatorFactory;
|
||||
this.queryFactory = queryFactory;
|
||||
this.tenantScope = tenantScope;
|
||||
this.currentPrincipalResolver = currentPrincipalResolver;
|
||||
this.claimExtractorProperties = claimExtractorProperties;
|
||||
this.userService = userService;
|
||||
this.auditService = auditService;
|
||||
this.tenantEntityManager = tenantEntityManager;
|
||||
this.queryFactory = queryFactory;
|
||||
this.tenantScope = tenantScope;
|
||||
this.currentPrincipalResolver = currentPrincipalResolver;
|
||||
this.claimExtractorProperties = claimExtractorProperties;
|
||||
this.userService = userService;
|
||||
this.auditService = auditService;
|
||||
this.tenantEntityManager = tenantEntityManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,23 +66,14 @@ public class UserTouchedIntegrationEventHandlerImpl implements UserTouchedIntegr
|
|||
|
||||
EventProcessingStatus status = EventProcessingStatus.Success;
|
||||
try {
|
||||
if (this.tenantScope.isMultitenant() && properties.getTenantId() != null) {
|
||||
TenantEntity tenant = queryFactory.query(TenantQuery.class).disableTracking().ids(properties.getTenantId()).firstAs(new BaseFieldSet().ensure(Tenant._id).ensure(Tenant._code));
|
||||
if (tenant == null) {
|
||||
logger.error("missing tenant from event message");
|
||||
return EventProcessingStatus.Error;
|
||||
}
|
||||
this.tenantScope.setTempTenant(tenantEntityManager, properties.getTenantId(), tenant.getCode());
|
||||
} else if (this.tenantScope.isMultitenant()) {
|
||||
// logger.error("missing tenant from event message");
|
||||
// return EventProcessingStatus.Error;
|
||||
this.tenantScope.setTempTenant(tenantEntityManager, null, this.tenantScope.getDefaultTenantCode());
|
||||
}
|
||||
|
||||
currentPrincipalResolver.push(InboxPrincipal.build(properties, claimExtractorProperties));
|
||||
|
||||
userService.persist(event, null);
|
||||
|
||||
try {
|
||||
this.tenantEntityManager.disableTenantFilters();
|
||||
userService.persist(event, null);
|
||||
} finally {
|
||||
this.tenantEntityManager.reloadTenantFilters();
|
||||
}
|
||||
auditService.track(AuditableAction.User_Persist, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("model", event)
|
||||
));
|
||||
|
@ -97,11 +83,6 @@ public class UserTouchedIntegrationEventHandlerImpl implements UserTouchedIntegr
|
|||
logger.error("Problem getting list of queue outbox. Skipping: {}", ex.getMessage(), ex);
|
||||
} finally {
|
||||
currentPrincipalResolver.pop();
|
||||
try {
|
||||
tenantScope.removeTempTenant(this.tenantEntityManager);
|
||||
} catch (InvalidApplicationException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
|
@ -3,7 +3,7 @@ package gr.cite.annotation.model.persist;
|
|||
import gr.cite.annotation.common.validation.BaseValidator;
|
||||
import gr.cite.annotation.convention.ConventionService;
|
||||
import gr.cite.annotation.errorcode.ErrorThesaurusProperties;
|
||||
import gr.cite.annotation.integrationevent.inbox.usertouch.UserTouchedIntegrationEvent;
|
||||
import gr.cite.annotation.integrationevent.inbox.usertouched.UserTouchedIntegrationEvent;
|
||||
import gr.cite.tools.validation.specification.Specification;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.MessageSource;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package gr.cite.annotation.service.user;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import gr.cite.annotation.integrationevent.inbox.usertouch.UserTouchedIntegrationEvent;
|
||||
import gr.cite.annotation.integrationevent.inbox.usertouched.UserTouchedIntegrationEvent;
|
||||
import gr.cite.annotation.model.User;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.exception.MyForbiddenException;
|
||||
|
|
|
@ -8,7 +8,7 @@ import gr.cite.annotation.common.enums.IsActive;
|
|||
import gr.cite.annotation.common.scope.tenant.TenantScope;
|
||||
import gr.cite.annotation.convention.ConventionService;
|
||||
import gr.cite.annotation.data.*;
|
||||
import gr.cite.annotation.integrationevent.inbox.usertouch.UserTouchedIntegrationEvent;
|
||||
import gr.cite.annotation.integrationevent.inbox.usertouched.UserTouchedIntegrationEvent;
|
||||
import gr.cite.annotation.model.Tenant;
|
||||
import gr.cite.annotation.model.User;
|
||||
import gr.cite.annotation.model.builder.UserBuilder;
|
||||
|
|
|
@ -5,16 +5,18 @@ import gr.cite.tools.fieldset.BaseFieldSet;
|
|||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
||||
import org.opencdmp.data.DescriptionEntity;
|
||||
import org.opencdmp.data.DmpEntity;
|
||||
import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent;
|
||||
import org.opencdmp.integrationevent.outbox.OutboxService;
|
||||
import org.opencdmp.model.description.Description;
|
||||
import org.opencdmp.model.dmp.Dmp;
|
||||
import org.opencdmp.query.DescriptionQuery;
|
||||
import org.opencdmp.query.DmpQuery;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -28,33 +30,36 @@ public class AnnotationEntityRemovalIntegrationEventHandlerImpl implements Annot
|
|||
private final OutboxService outboxService;
|
||||
|
||||
private final QueryFactory queryFactory;
|
||||
private final TenantScope tenantScope;
|
||||
|
||||
public AnnotationEntityRemovalIntegrationEventHandlerImpl(OutboxService outboxService, QueryFactory queryFactory, TenantScope tenantScope) {
|
||||
this.outboxService = outboxService;
|
||||
this.queryFactory = queryFactory;
|
||||
this.tenantScope = tenantScope;
|
||||
}
|
||||
|
||||
private void handle(AnnotationEntitiesRemovalIntegrationEvent event) throws InvalidApplicationException {
|
||||
private void handle(AnnotationEntitiesRemovalIntegrationEvent event, UUID tenantId) {
|
||||
OutboxIntegrationEvent message = new OutboxIntegrationEvent();
|
||||
message.setMessageId(UUID.randomUUID());
|
||||
message.setType(OutboxIntegrationEvent.ANNOTATION_ENTITY_REMOVE);
|
||||
message.setEvent(event);
|
||||
if (this.tenantScope.isSet()) message.setTenantId(this.tenantScope.getTenant());
|
||||
this.outboxService.publish(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDescription(UUID descriptionId) throws InvalidApplicationException {
|
||||
AnnotationEntitiesRemovalIntegrationEvent event = new AnnotationEntitiesRemovalIntegrationEvent();
|
||||
public void handleDescription(UUID descriptionId) {
|
||||
DescriptionEntity description = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(descriptionId).firstAs(new BaseFieldSet().ensure(Description._id).ensure(DescriptionEntity._tenantId));
|
||||
if (description == null) return;
|
||||
|
||||
AnnotationEntitiesRemovalIntegrationEvent event = new AnnotationEntitiesRemovalIntegrationEvent();
|
||||
event.setEntityIds(List.of(descriptionId));
|
||||
|
||||
this.handle(event);
|
||||
this.handle(event, description.getTenantId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDmp(UUID dmpId) throws InvalidApplicationException {
|
||||
public void handleDmp(UUID dmpId) {
|
||||
DmpEntity dmp = this.queryFactory.query(DmpQuery.class).disableTracking().ids(dmpId).firstAs(new BaseFieldSet().ensure(Dmp._id).ensure(DmpEntity._tenantId));
|
||||
if(dmp == null) return;
|
||||
|
||||
List<DescriptionEntity> descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().dmpIds(dmpId).collectAs(new BaseFieldSet().ensure(Description._id));
|
||||
|
||||
AnnotationEntitiesRemovalIntegrationEvent event = new AnnotationEntitiesRemovalIntegrationEvent();
|
||||
|
@ -63,6 +68,6 @@ public class AnnotationEntityRemovalIntegrationEventHandlerImpl implements Annot
|
|||
|
||||
for (DescriptionEntity description : descriptionEntities) event.getEntityIds().add(description.getId());
|
||||
|
||||
this.handle(event);
|
||||
this.handle(event, dmp.getTenantId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class AnnotationEntitiesTouchedIntegrationEvent extends TrackedEvent {
|
|||
private List<AnnotationEntityTouchedIntegrationEvent> events;
|
||||
|
||||
public List<AnnotationEntityTouchedIntegrationEvent> getEvents() {
|
||||
return events;
|
||||
return this.events;
|
||||
}
|
||||
|
||||
public void setEvents(List<AnnotationEntityTouchedIntegrationEvent> events) {
|
||||
|
@ -24,7 +24,7 @@ public class AnnotationEntitiesTouchedIntegrationEvent extends TrackedEvent {
|
|||
private List<UUID> userIds;
|
||||
|
||||
public UUID getEntityId() {
|
||||
return entityId;
|
||||
return this.entityId;
|
||||
}
|
||||
|
||||
public void setEntityId(UUID entityId) {
|
||||
|
@ -32,7 +32,7 @@ public class AnnotationEntitiesTouchedIntegrationEvent extends TrackedEvent {
|
|||
}
|
||||
|
||||
public List<UUID> getUserIds() {
|
||||
return userIds;
|
||||
return this.userIds;
|
||||
}
|
||||
|
||||
public void setUserIds(List<UUID> userIds) {
|
||||
|
|
|
@ -3,8 +3,6 @@ package org.opencdmp.integrationevent.outbox.notification;
|
|||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
||||
import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent;
|
||||
import org.opencdmp.integrationevent.outbox.OutboxService;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.annotation.RequestScope;
|
||||
|
@ -16,8 +14,6 @@ import java.util.UUID;
|
|||
@RequestScope
|
||||
public class NotifyIntegrationEventHandlerImpl implements NotifyIntegrationEventHandler {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(NotifyIntegrationEventHandlerImpl.class));
|
||||
|
||||
private final OutboxService outboxService;
|
||||
private final TenantScope tenantScope;
|
||||
|
||||
|
@ -34,7 +30,7 @@ public class NotifyIntegrationEventHandlerImpl implements NotifyIntegrationEvent
|
|||
message.setMessageId(UUID.randomUUID());
|
||||
message.setType(OutboxIntegrationEvent.NOTIFY);
|
||||
message.setEvent(event);
|
||||
if (this.tenantScope.isSet()) message.setTenantId(tenantScope.getTenant());
|
||||
if (this.tenantScope.isSet()) message.setTenantId(this.tenantScope.getTenant());
|
||||
this.outboxService.publish(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package org.opencdmp.integrationevent.outbox.tenantdefaultlocaleremoval;
|
||||
|
||||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent;
|
||||
import org.opencdmp.integrationevent.outbox.OutboxService;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -19,13 +18,11 @@ public class TenantDefaultLocaleRemovalIntegrationEventHandlerImpl implements Te
|
|||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantDefaultLocaleRemovalIntegrationEventHandlerImpl.class));
|
||||
|
||||
private final OutboxService outboxService;
|
||||
private final TenantScope tenantScope;
|
||||
|
||||
@Autowired
|
||||
public TenantDefaultLocaleRemovalIntegrationEventHandlerImpl(
|
||||
OutboxService outboxService, TenantScope tenantScope) {
|
||||
OutboxService outboxService) {
|
||||
this.outboxService = outboxService;
|
||||
this.tenantScope = tenantScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,7 +31,7 @@ public class TenantDefaultLocaleRemovalIntegrationEventHandlerImpl implements Te
|
|||
message.setMessageId(UUID.randomUUID());
|
||||
message.setType(OutboxIntegrationEvent.TENANT_DEFAULT_LOCALE_REMOVAL);
|
||||
message.setEvent(event);
|
||||
if (this.tenantScope.isSet()) message.setTenantId(tenantScope.getTenant());
|
||||
message.setTenantId(event.getTenantId());
|
||||
this.outboxService.publish(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package org.opencdmp.integrationevent.outbox.tenantdefaultlocaletouched;
|
||||
|
||||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent;
|
||||
import org.opencdmp.integrationevent.outbox.OutboxService;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -19,13 +18,11 @@ public class TenantDefaultLocaleTouchedIntegrationEventHandlerImpl implements Te
|
|||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(TenantDefaultLocaleTouchedIntegrationEventHandlerImpl.class));
|
||||
|
||||
private final OutboxService outboxService;
|
||||
private final TenantScope tenantScope;
|
||||
|
||||
@Autowired
|
||||
public TenantDefaultLocaleTouchedIntegrationEventHandlerImpl(
|
||||
OutboxService outboxService, TenantScope tenantScope) {
|
||||
OutboxService outboxService) {
|
||||
this.outboxService = outboxService;
|
||||
this.tenantScope = tenantScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,7 +31,7 @@ public class TenantDefaultLocaleTouchedIntegrationEventHandlerImpl implements Te
|
|||
message.setMessageId(UUID.randomUUID());
|
||||
message.setType(OutboxIntegrationEvent.TENANT_DEFAULT_LOCALE_TOUCHED);
|
||||
message.setEvent(event);
|
||||
if (this.tenantScope.isSet()) message.setTenantId(tenantScope.getTenant());
|
||||
message.setTenantId(event.getTenantId());
|
||||
this.outboxService.publish(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package org.opencdmp.integrationevent.outbox.userremoval;
|
||||
|
||||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent;
|
||||
import org.opencdmp.integrationevent.outbox.OutboxService;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
@ -14,7 +13,7 @@ import javax.management.InvalidApplicationException;
|
|||
import java.util.UUID;
|
||||
|
||||
@Component("outboxuserremovalintegrationeventhandler")
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class UserRemovalIntegrationEventHandlerImpl implements UserRemovalIntegrationEventHandler {
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(UserRemovalIntegrationEventHandlerImpl.class));
|
||||
|
@ -22,12 +21,10 @@ public class UserRemovalIntegrationEventHandlerImpl implements UserRemovalIntegr
|
|||
private final OutboxService outboxService;
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
private final TenantScope tenantScope;
|
||||
|
||||
public UserRemovalIntegrationEventHandlerImpl(OutboxService outboxService, ApplicationContext applicationContext, TenantScope tenantScope) {
|
||||
public UserRemovalIntegrationEventHandlerImpl(OutboxService outboxService, ApplicationContext applicationContext) {
|
||||
this.outboxService = outboxService;
|
||||
this.applicationContext = applicationContext;
|
||||
this.tenantScope = tenantScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,7 +36,6 @@ public class UserRemovalIntegrationEventHandlerImpl implements UserRemovalIntegr
|
|||
OutboxIntegrationEvent message = new OutboxIntegrationEvent();
|
||||
message.setMessageId(UUID.randomUUID());
|
||||
message.setType(OutboxIntegrationEvent.USER_REMOVE);
|
||||
if (this.tenantScope.isSet()) message.setTenantId(tenantScope.getTenant());
|
||||
UserRemovalIntegrationEvent event = new UserRemovalIntegrationEvent();
|
||||
event.setUserId(userId);
|
||||
message.setEvent(event);
|
||||
|
|
|
@ -5,7 +5,6 @@ import gr.cite.tools.exception.MyNotFoundException;
|
|||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.opencdmp.commons.JsonHandlingService;
|
||||
import org.opencdmp.commons.scope.tenant.TenantScope;
|
||||
import org.opencdmp.commons.types.user.AdditionalInfoEntity;
|
||||
import org.opencdmp.data.*;
|
||||
import org.opencdmp.integrationevent.outbox.OutboxIntegrationEvent;
|
||||
|
@ -39,16 +38,14 @@ public class UserTouchedIntegrationEventHandlerImpl implements UserTouchedIntegr
|
|||
private final OutboxService outboxService;
|
||||
private final JsonHandlingService jsonHandlingService;
|
||||
private final MessageSource messageSource;
|
||||
private final TenantScope tenantScope;
|
||||
private final TenantEntityManager entityManager;
|
||||
|
||||
private final QueryFactory queryFactory;
|
||||
public UserTouchedIntegrationEventHandlerImpl(
|
||||
OutboxService outboxService, JsonHandlingService jsonHandlingService, MessageSource messageSource, TenantScope tenantScope, TenantEntityManager entityManager, QueryFactory queryFactory) {
|
||||
OutboxService outboxService, JsonHandlingService jsonHandlingService, MessageSource messageSource, TenantEntityManager entityManager, QueryFactory queryFactory) {
|
||||
this.outboxService = outboxService;
|
||||
this.jsonHandlingService = jsonHandlingService;
|
||||
this.messageSource = messageSource;
|
||||
this.tenantScope = tenantScope;
|
||||
this.entityManager = entityManager;
|
||||
this.queryFactory = queryFactory;
|
||||
}
|
||||
|
@ -58,7 +55,6 @@ public class UserTouchedIntegrationEventHandlerImpl implements UserTouchedIntegr
|
|||
OutboxIntegrationEvent message = new OutboxIntegrationEvent();
|
||||
message.setMessageId(UUID.randomUUID());
|
||||
message.setType(OutboxIntegrationEvent.USER_TOUCH);
|
||||
if (this.tenantScope.isSet()) message.setTenantId(this.tenantScope.getTenant());
|
||||
|
||||
try {
|
||||
this.entityManager.disableTenantFilters();
|
||||
|
|
|
@ -428,6 +428,8 @@ public class DmpQuery extends QueryBase<DmpEntity> {
|
|||
return DmpEntity._publicAfter;
|
||||
else if (item.match(Dmp._versionStatus))
|
||||
return DmpEntity._versionStatus;
|
||||
else if (item.match(DmpEntity._tenantId))
|
||||
return DmpEntity._tenantId;
|
||||
else if (item.match(Dmp._belongsToCurrentTenant))
|
||||
return DmpEntity._tenantId;
|
||||
else
|
||||
|
|
|
@ -163,32 +163,34 @@ public class TenantServiceImpl implements TenantService {
|
|||
List<UserRoleEntity> existingItems;
|
||||
List<UserCredentialEntity> userCredentialEntities;
|
||||
try {
|
||||
this.tenantScope.setTempTenant(this.entityManager, null, this.tenantScope.getDefaultTenantCode());
|
||||
this.entityManager.disableTenantFilters();
|
||||
|
||||
existingItems = this.queryFactory.query(UserRoleQuery.class).disableTracking().tenantIsSet(false).roles(this.authorizationProperties.getGlobalAdminRole()).collect();
|
||||
userCredentialEntities = this.queryFactory.query(UserCredentialQuery.class).disableTracking().userIds(existingItems.stream().map(UserRoleEntity::getUserId).distinct().toList()).collect();
|
||||
} finally {
|
||||
this.tenantScope.removeTempTenant(this.entityManager);
|
||||
}
|
||||
try {
|
||||
this.tenantScope.setTempTenant(this.entityManager, tenant.getId(), tenant.getCode());
|
||||
|
||||
List<String> keycloakIdsToAddToTenantGroup = new ArrayList<>();
|
||||
for (UUID userId : existingItems.stream().map(UserRoleEntity::getUserId).distinct().toList()) {
|
||||
UserCredentialEntity userCredential = userCredentialEntities.stream().filter(x-> !this.conventionService.isNullOrEmpty(x.getExternalId()) && x.getUserId().equals(userId)).findFirst().orElse(null);
|
||||
if (userCredential == null) continue;
|
||||
UserRoleEntity item = new UserRoleEntity();
|
||||
item.setId(UUID.randomUUID());
|
||||
item.setUserId(userId);
|
||||
item.setTenantId(tenant.getId());
|
||||
item.setRole(this.authorizationProperties.getTenantAdminRole());
|
||||
item.setCreatedAt(Instant.now());
|
||||
this.entityManager.persist(item);
|
||||
keycloakIdsToAddToTenantGroup.add(userCredential.getExternalId());
|
||||
this.keycloakService.addUserToTenantRoleGroup(userCredential.getExternalId(), this.tenantScope.getTenantCode(), this.authorizationProperties.getTenantAdminRole());
|
||||
}
|
||||
|
||||
this.entityManager.flush();
|
||||
|
||||
for (String externalId : keycloakIdsToAddToTenantGroup) {
|
||||
this.keycloakService.addUserToTenantRoleGroup(externalId, this.tenantScope.getTenantCode(), this.authorizationProperties.getTenantAdminRole());
|
||||
}
|
||||
} finally {
|
||||
this.tenantScope.removeTempTenant(this.entityManager);
|
||||
this.entityManager.reloadTenantFilters();
|
||||
}
|
||||
|
||||
this.entityManager.flush();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -280,8 +280,12 @@ public class UserServiceImpl implements UserService {
|
|||
logger.debug("deleting User: {}", id);
|
||||
|
||||
this.authorizationService.authorizeForce(Permission.DeleteUser);
|
||||
|
||||
this.deleterFactory.deleter(UserDeleter.class).deleteAndSaveByIds(List.of(id));
|
||||
try {
|
||||
this.entityManager.disableTenantFilters();
|
||||
this.deleterFactory.deleter(UserDeleter.class).deleteAndSaveByIds(List.of(id));
|
||||
} finally {
|
||||
this.entityManager.reloadTenantFilters();
|
||||
}
|
||||
this.userRemovalIntegrationEventHandler.handle(id);
|
||||
}
|
||||
|
||||
|
@ -341,7 +345,7 @@ public class UserServiceImpl implements UserService {
|
|||
|
||||
private void applyGlobalRoles(UUID userId, UserRolePatchPersist model) throws InvalidApplicationException {
|
||||
try {
|
||||
this.tenantScope.setTempTenant(this.entityManager, null, this.tenantScope.getDefaultTenantCode());
|
||||
this.entityManager.disableTenantFilters();
|
||||
|
||||
List<UserRoleEntity> existingItems = this.queryFactory.query(UserRoleQuery.class).userIds(userId).tenantIsSet(false).roles(this.authorizationProperties.getAllowedGlobalRoles()).collect();
|
||||
List<UUID> foundIds = new ArrayList<>();
|
||||
|
@ -365,7 +369,7 @@ public class UserServiceImpl implements UserService {
|
|||
|
||||
this.entityManager.flush();
|
||||
} finally {
|
||||
this.tenantScope.removeTempTenant(this.entityManager);
|
||||
this.entityManager.reloadTenantFilters();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -623,131 +627,155 @@ public class UserServiceImpl implements UserService {
|
|||
|
||||
}
|
||||
|
||||
private void syncKeycloakRoles(UUID userId){
|
||||
List<UserCredentialEntity> userCredentials = this.queryFactory.query(UserCredentialQuery.class).disableTracking().userIds(userId).collect();
|
||||
List<UserRoleEntity> userRoles = this.queryFactory.query(UserRoleQuery.class).disableTracking().userIds(userId).collect();
|
||||
List<TenantEntity> tenants = this.queryFactory.query(TenantQuery.class).disableTracking().ids(userRoles.stream().map(TenantScopedBaseEntity::getTenantId).filter(Objects::nonNull).toList()).collect();
|
||||
private void syncKeycloakRoles(UUID userId) throws InvalidApplicationException {
|
||||
try {
|
||||
this.entityManager.disableTenantFilters();
|
||||
List<UserCredentialEntity> userCredentials = this.queryFactory.query(UserCredentialQuery.class).disableTracking().userIds(userId).collect();
|
||||
List<UserRoleEntity> userRoles = this.queryFactory.query(UserRoleQuery.class).disableTracking().userIds(userId).collect();
|
||||
List<TenantEntity> tenants = this.queryFactory.query(TenantQuery.class).disableTracking().ids(userRoles.stream().map(TenantScopedBaseEntity::getTenantId).filter(Objects::nonNull).toList()).collect();
|
||||
|
||||
for (UserCredentialEntity userCredential : userCredentials){
|
||||
this.keycloakService.removeFromAllGroups(userCredential.getExternalId());
|
||||
for (UserRoleEntity userRole : userRoles) {
|
||||
if (this.authorizationProperties.getAllowedGlobalRoles().contains(userRole.getRole())){
|
||||
this.keycloakService.addUserToGlobalRoleGroup(userCredential.getExternalId(), userRole.getRole());
|
||||
} else if (this.authorizationProperties.getAllowedTenantRoles().contains(userRole.getRole())){
|
||||
String tenantCode = userRole.getTenantId() == null ? this.tenantScope.getDefaultTenantCode() : tenants.stream().filter(x-> x.getId().equals(userRole.getTenantId())).map(TenantEntity::getCode).findFirst().orElse(null);
|
||||
if (!this.conventionService.isNullOrEmpty(tenantCode)) this.keycloakService.addUserToTenantRoleGroup(userCredential.getExternalId(), tenantCode, userRole.getRole());
|
||||
for (UserCredentialEntity userCredential : userCredentials){
|
||||
this.keycloakService.removeFromAllGroups(userCredential.getExternalId());
|
||||
for (UserRoleEntity userRole : userRoles) {
|
||||
if (this.authorizationProperties.getAllowedGlobalRoles().contains(userRole.getRole())){
|
||||
this.keycloakService.addUserToGlobalRoleGroup(userCredential.getExternalId(), userRole.getRole());
|
||||
} else if (this.authorizationProperties.getAllowedTenantRoles().contains(userRole.getRole())){
|
||||
String tenantCode = userRole.getTenantId() == null ? this.tenantScope.getDefaultTenantCode() : tenants.stream().filter(x-> x.getId().equals(userRole.getTenantId())).map(TenantEntity::getCode).findFirst().orElse(null);
|
||||
if (!this.conventionService.isNullOrEmpty(tenantCode)) this.keycloakService.addUserToTenantRoleGroup(userCredential.getExternalId(), tenantCode, userRole.getRole());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} finally {
|
||||
this.entityManager.reloadTenantFilters();
|
||||
}
|
||||
}
|
||||
|
||||
private void mergeNewUserToOld(UserEntity newUser, UserEntity oldUser) throws IOException, InvalidApplicationException {
|
||||
List<UserCredentialEntity> userCredentials = this.queryFactory.query(UserCredentialQuery.class).userIds(oldUser.getId()).collect();
|
||||
for (UserCredentialEntity userCredential : userCredentials){
|
||||
userCredential.setUserId(newUser.getId());
|
||||
this.entityManager.merge(userCredential);
|
||||
}
|
||||
|
||||
List<UserContactInfoEntity> userContacts = this.queryFactory.query(UserContactInfoQuery.class).userIds(oldUser.getId()).collect();
|
||||
UserContactInfoQuery newUserContactInfoQuery = this.queryFactory.query(UserContactInfoQuery.class).userIds(newUser.getId());
|
||||
newUserContactInfoQuery.setOrder(new Ordering().addDescending(UserContactInfo._ordinal));
|
||||
UserContactInfoEntity newUserContactInfo = newUserContactInfoQuery.first();
|
||||
int ordinal = newUserContactInfo == null ? 0 : newUserContactInfo.getOrdinal() + 1;
|
||||
for (UserContactInfoEntity userContactInfo : userContacts){
|
||||
userContactInfo.setUserId(newUser.getId());
|
||||
userContactInfo.setOrdinal(ordinal);
|
||||
this.entityManager.merge(userContactInfo);
|
||||
ordinal++;
|
||||
}
|
||||
|
||||
List<UserRoleEntity> userRoles = this.queryFactory.query(UserRoleQuery.class).userIds(oldUser.getId()).collect();
|
||||
List<UserRoleEntity> newUserRoles = this.queryFactory.query(UserRoleQuery.class).userIds(newUser.getId()).collect();
|
||||
List<UserRoleEntity> rolesToDelete = new ArrayList<>();
|
||||
for (UserRoleEntity userRole : userRoles){
|
||||
if (newUserRoles.stream().anyMatch(x-> x.getRole().equals(userRole.getRole()))) {
|
||||
rolesToDelete.add(userRole);
|
||||
} else {
|
||||
userRole.setUserId(newUser.getId());
|
||||
this.entityManager.merge(userRole);
|
||||
try {
|
||||
this.entityManager.disableTenantFilters();
|
||||
List<UserCredentialEntity> userCredentials = this.queryFactory.query(UserCredentialQuery.class).userIds(oldUser.getId()).collect();
|
||||
for (UserCredentialEntity userCredential : userCredentials) {
|
||||
userCredential.setUserId(newUser.getId());
|
||||
this.entityManager.merge(userCredential);
|
||||
}
|
||||
}
|
||||
this.deleterFactory.deleter(UserRoleDeleter.class).delete(rolesToDelete);
|
||||
|
||||
List<UserSettingsEntity> userSettings = this.queryFactory.query(UserSettingsQuery.class).entityIds(oldUser.getId()).collect();
|
||||
List<UserSettingsEntity> newUserSettings = this.queryFactory.query(UserSettingsQuery.class).entityIds(newUser.getId()).collect();
|
||||
List<UserSettingsEntity> userSettingsToDelete = new ArrayList<>();
|
||||
for (UserSettingsEntity userSetting : userSettings){
|
||||
if (newUserSettings.stream().anyMatch(x-> x.getKey().equals(userSetting.getKey()))) {
|
||||
userSettingsToDelete.add(userSetting);
|
||||
} else {
|
||||
userSetting.setEntityId(newUser.getId());
|
||||
this.entityManager.merge(userSetting);
|
||||
List<UserContactInfoEntity> userContacts = this.queryFactory.query(UserContactInfoQuery.class).userIds(oldUser.getId()).collect();
|
||||
UserContactInfoQuery newUserContactInfoQuery = this.queryFactory.query(UserContactInfoQuery.class).userIds(newUser.getId());
|
||||
newUserContactInfoQuery.setOrder(new Ordering().addDescending(UserContactInfo._ordinal));
|
||||
UserContactInfoEntity newUserContactInfo = newUserContactInfoQuery.first();
|
||||
int ordinal = newUserContactInfo == null ? 0 : newUserContactInfo.getOrdinal() + 1;
|
||||
for (UserContactInfoEntity userContactInfo : userContacts) {
|
||||
userContactInfo.setUserId(newUser.getId());
|
||||
userContactInfo.setOrdinal(ordinal);
|
||||
this.entityManager.merge(userContactInfo);
|
||||
ordinal++;
|
||||
}
|
||||
}
|
||||
this.deleterFactory.deleter(UserSettingsSettingsDeleter.class).delete(userSettingsToDelete);
|
||||
|
||||
List<TagEntity> tags = this.queryFactory.query(TagQuery.class).createdByIds(oldUser.getId()).collect();
|
||||
for (TagEntity tag : tags){
|
||||
tag.setCreatedById(newUser.getId());
|
||||
this.entityManager.merge(tag);
|
||||
}
|
||||
List<UserRoleEntity> userRoles = this.queryFactory.query(UserRoleQuery.class).userIds(oldUser.getId()).collect();
|
||||
List<UserRoleEntity> newUserRoles = this.queryFactory.query(UserRoleQuery.class).userIds(newUser.getId()).collect();
|
||||
List<UserRoleEntity> rolesToDelete = new ArrayList<>();
|
||||
for (UserRoleEntity userRole : userRoles) {
|
||||
if (newUserRoles.stream().anyMatch(x -> Objects.equals(x.getTenantId(), userRole.getTenantId()) && x.getRole().equals(userRole.getRole()))) {
|
||||
rolesToDelete.add(userRole);
|
||||
} else {
|
||||
userRole.setUserId(newUser.getId());
|
||||
this.entityManager.merge(userRole);
|
||||
}
|
||||
}
|
||||
this.deleterFactory.deleter(UserRoleDeleter.class).delete(rolesToDelete);
|
||||
|
||||
List<StorageFileEntity> storageFiles = this.queryFactory.query(StorageFileQuery.class).ownerIds(oldUser.getId()).collect();
|
||||
for (StorageFileEntity storageFile : storageFiles){
|
||||
storageFile.setOwnerId(newUser.getId());
|
||||
this.entityManager.merge(storageFile);
|
||||
}
|
||||
List<TenantUserEntity> userTenantUsers = this.queryFactory.query(TenantUserQuery.class).userIds(oldUser.getId()).collect();
|
||||
List<TenantUserEntity> newTenantUsers = this.queryFactory.query(TenantUserQuery.class).userIds(newUser.getId()).collect();
|
||||
List<TenantUserEntity> tenantUsersToDelete = new ArrayList<>();
|
||||
for (TenantUserEntity userTenantUser : userTenantUsers) {
|
||||
if (newTenantUsers.stream().anyMatch(x -> Objects.equals(x.getTenantId(), userTenantUser.getTenantId()))) {
|
||||
tenantUsersToDelete.add(userTenantUser);
|
||||
} else {
|
||||
userTenantUser.setUserId(newUser.getId());
|
||||
this.entityManager.merge(userTenantUser);
|
||||
}
|
||||
}
|
||||
this.deleterFactory.deleter(TenantUserDeleter.class).delete(tenantUsersToDelete);
|
||||
|
||||
List<LockEntity> locks = this.queryFactory.query(LockQuery.class).lockedByIds(oldUser.getId()).collect();
|
||||
for (LockEntity lock : locks){
|
||||
lock.setLockedBy(newUser.getId());
|
||||
this.entityManager.merge(lock);
|
||||
}
|
||||
List<UserSettingsEntity> userSettings = this.queryFactory.query(UserSettingsQuery.class).entityIds(oldUser.getId()).collect();
|
||||
List<UserSettingsEntity> newUserSettings = this.queryFactory.query(UserSettingsQuery.class).entityIds(newUser.getId()).collect();
|
||||
List<UserSettingsEntity> userSettingsToDelete = new ArrayList<>();
|
||||
for (UserSettingsEntity userSetting : userSettings) {
|
||||
if (newUserSettings.stream().anyMatch(x -> Objects.equals(x.getTenantId(), userSetting.getTenantId()) &&x.getKey().equals(userSetting.getKey()))) {
|
||||
userSettingsToDelete.add(userSetting);
|
||||
} else {
|
||||
userSetting.setEntityId(newUser.getId());
|
||||
this.entityManager.merge(userSetting);
|
||||
}
|
||||
}
|
||||
this.deleterFactory.deleter(UserSettingsSettingsDeleter.class).delete(userSettingsToDelete);
|
||||
|
||||
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class).userIds(oldUser.getId()).collect();
|
||||
for (DmpUserEntity dmpUser : dmpUsers){
|
||||
dmpUser.setUserId(newUser.getId());
|
||||
this.entityManager.merge(dmpUser);
|
||||
}
|
||||
List<TagEntity> tags = this.queryFactory.query(TagQuery.class).createdByIds(oldUser.getId()).collect();
|
||||
for (TagEntity tag : tags) {
|
||||
tag.setCreatedById(newUser.getId());
|
||||
this.entityManager.merge(tag);
|
||||
}
|
||||
|
||||
List<UserDescriptionTemplateEntity> userDescriptionTemplates = this.queryFactory.query(UserDescriptionTemplateQuery.class).userIds(oldUser.getId()).collect();
|
||||
for (UserDescriptionTemplateEntity userDescriptionTemplate : userDescriptionTemplates){
|
||||
userDescriptionTemplate.setUserId(newUser.getId());
|
||||
this.entityManager.merge(userDescriptionTemplate);
|
||||
}
|
||||
List<StorageFileEntity> storageFiles = this.queryFactory.query(StorageFileQuery.class).ownerIds(oldUser.getId()).collect();
|
||||
for (StorageFileEntity storageFile : storageFiles) {
|
||||
storageFile.setOwnerId(newUser.getId());
|
||||
this.entityManager.merge(storageFile);
|
||||
}
|
||||
|
||||
List<DmpEntity> dmps = this.queryFactory.query(DmpQuery.class).creatorIds(oldUser.getId()).collect();
|
||||
for (DmpEntity dmp : dmps){
|
||||
dmp.setCreatorId(newUser.getId());
|
||||
this.entityManager.merge(dmp);
|
||||
}
|
||||
List<LockEntity> locks = this.queryFactory.query(LockQuery.class).lockedByIds(oldUser.getId()).collect();
|
||||
for (LockEntity lock : locks) {
|
||||
lock.setLockedBy(newUser.getId());
|
||||
this.entityManager.merge(lock);
|
||||
}
|
||||
|
||||
List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).createdByIds(oldUser.getId()).collect();
|
||||
for (DescriptionEntity description : descriptions){
|
||||
description.setCreatedById(newUser.getId());
|
||||
this.entityManager.merge(description);
|
||||
}
|
||||
List<DmpUserEntity> dmpUsers = this.queryFactory.query(DmpUserQuery.class).userIds(oldUser.getId()).collect();
|
||||
for (DmpUserEntity dmpUser : dmpUsers) {
|
||||
dmpUser.setUserId(newUser.getId());
|
||||
this.entityManager.merge(dmpUser);
|
||||
}
|
||||
|
||||
oldUser.setIsActive(IsActive.Inactive);
|
||||
List<UserDescriptionTemplateEntity> userDescriptionTemplates = this.queryFactory.query(UserDescriptionTemplateQuery.class).userIds(oldUser.getId()).collect();
|
||||
for (UserDescriptionTemplateEntity userDescriptionTemplate : userDescriptionTemplates) {
|
||||
userDescriptionTemplate.setUserId(newUser.getId());
|
||||
this.entityManager.merge(userDescriptionTemplate);
|
||||
}
|
||||
|
||||
this.entityManager.merge(oldUser);
|
||||
List<DmpEntity> dmps = this.queryFactory.query(DmpQuery.class).creatorIds(oldUser.getId()).collect();
|
||||
for (DmpEntity dmp : dmps) {
|
||||
dmp.setCreatorId(newUser.getId());
|
||||
this.entityManager.merge(dmp);
|
||||
}
|
||||
|
||||
this.entityManager.flush();
|
||||
List<DescriptionEntity> descriptions = this.queryFactory.query(DescriptionQuery.class).createdByIds(oldUser.getId()).collect();
|
||||
for (DescriptionEntity description : descriptions) {
|
||||
description.setCreatedById(newUser.getId());
|
||||
this.entityManager.merge(description);
|
||||
}
|
||||
|
||||
for (DmpEntity dmp : dmps){
|
||||
this.elasticService.persistDmp(dmp);
|
||||
}
|
||||
oldUser.setIsActive(IsActive.Inactive);
|
||||
|
||||
for (DescriptionEntity description : descriptions){
|
||||
this.elasticService.persistDescription(description);
|
||||
}
|
||||
this.entityManager.merge(oldUser);
|
||||
|
||||
for (DmpEntity dmp : dmps){
|
||||
this.annotationEntityTouchedIntegrationEventHandler.handleDmp(dmp.getId());
|
||||
}
|
||||
this.entityManager.flush();
|
||||
|
||||
for (DescriptionEntity description : descriptions){
|
||||
this.annotationEntityTouchedIntegrationEventHandler.handleDescription(description.getId());
|
||||
for (DmpEntity dmp : dmps) {
|
||||
this.elasticService.persistDmp(dmp);
|
||||
}
|
||||
|
||||
for (DescriptionEntity description : descriptions) {
|
||||
this.elasticService.persistDescription(description);
|
||||
}
|
||||
|
||||
for (DmpEntity dmp : dmps) {
|
||||
this.annotationEntityTouchedIntegrationEventHandler.handleDmp(dmp.getId());
|
||||
}
|
||||
|
||||
for (DescriptionEntity description : descriptions) {
|
||||
this.annotationEntityTouchedIntegrationEventHandler.handleDescription(description.getId());
|
||||
}
|
||||
} finally {
|
||||
this.entityManager.reloadTenantFilters();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ public class UserRemovalIntegrationEventHandlerImpl implements UserRemovalIntegr
|
|||
private final ErrorThesaurusProperties errors;
|
||||
|
||||
private final MessageSource messageSource;
|
||||
private final QueryFactory queryFactory;
|
||||
private final TenantScope tenantScope;
|
||||
private final CurrentPrincipalResolver currentPrincipalResolver;
|
||||
private final ClaimExtractorProperties claimExtractorProperties;
|
||||
|
@ -54,12 +53,11 @@ public class UserRemovalIntegrationEventHandlerImpl implements UserRemovalIntegr
|
|||
public UserRemovalIntegrationEventHandlerImpl(
|
||||
JsonHandlingService jsonHandlingService,
|
||||
ErrorThesaurusProperties errors,
|
||||
MessageSource messageSource, QueryFactory queryFactory, TenantScope tenantScope, CurrentPrincipalResolver currentPrincipalResolver, ClaimExtractorProperties claimExtractorProperties, UserRemovalConsistencyHandler userRemovalConsistencyHandler, UserService userService, AuditService auditService, TenantEntityManager tenantEntityManager
|
||||
MessageSource messageSource, TenantScope tenantScope, CurrentPrincipalResolver currentPrincipalResolver, ClaimExtractorProperties claimExtractorProperties, UserRemovalConsistencyHandler userRemovalConsistencyHandler, UserService userService, AuditService auditService, TenantEntityManager tenantEntityManager
|
||||
) {
|
||||
this.jsonHandlingService = jsonHandlingService;
|
||||
this.errors = errors;
|
||||
this.messageSource = messageSource;
|
||||
this.queryFactory = queryFactory;
|
||||
this.tenantScope = tenantScope;
|
||||
this.currentPrincipalResolver = currentPrincipalResolver;
|
||||
this.claimExtractorProperties = claimExtractorProperties;
|
||||
|
@ -81,29 +79,21 @@ public class UserRemovalIntegrationEventHandlerImpl implements UserRemovalIntegr
|
|||
|
||||
EventProcessingStatus status = EventProcessingStatus.Success;
|
||||
try {
|
||||
if (this.tenantScope.isMultitenant() && properties.getTenantId() != null) {
|
||||
TenantEntity tenant = queryFactory.query(TenantQuery.class).disableTracking().ids(properties.getTenantId()).firstAs(new BaseFieldSet().ensure(Tenant._id).ensure(Tenant._code));
|
||||
if (tenant == null) {
|
||||
logger.error("missing tenant from event message");
|
||||
return EventProcessingStatus.Error;
|
||||
}
|
||||
this.tenantScope.setTempTenant(tenantEntityManager, properties.getTenantId(), tenant.getCode());
|
||||
} else if (this.tenantScope.isMultitenant()) {
|
||||
// logger.error("missing tenant from event message");
|
||||
// return EventProcessingStatus.Error;
|
||||
this.tenantScope.setTempTenant(tenantEntityManager, null, this.tenantScope.getDefaultTenantCode());
|
||||
}
|
||||
|
||||
currentPrincipalResolver.push(InboxPrincipal.build(properties, claimExtractorProperties));
|
||||
|
||||
if (!(userRemovalConsistencyHandler.isConsistent(new UserRemovalConsistencyPredicates(event.getUserId())))) {
|
||||
status = EventProcessingStatus.Postponed;
|
||||
currentPrincipalResolver.pop();
|
||||
tenantScope.removeTempTenant(this.tenantEntityManager);
|
||||
return status;
|
||||
}
|
||||
try{
|
||||
this.tenantEntityManager.disableTenantFilters();
|
||||
if (!(userRemovalConsistencyHandler.isConsistent(new UserRemovalConsistencyPredicates(event.getUserId())))) {
|
||||
status = EventProcessingStatus.Postponed;
|
||||
currentPrincipalResolver.pop();
|
||||
tenantScope.removeTempTenant(this.tenantEntityManager);
|
||||
return status;
|
||||
}
|
||||
|
||||
userService.deleteAndSave(event.getUserId());
|
||||
userService.deleteAndSave(event.getUserId());
|
||||
} finally {
|
||||
this.tenantEntityManager.reloadTenantFilters();
|
||||
}
|
||||
|
||||
auditService.track(AuditableAction.User_Delete, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("id", event.getUserId())
|
||||
|
@ -114,11 +104,6 @@ public class UserRemovalIntegrationEventHandlerImpl implements UserRemovalIntegr
|
|||
logger.error("Problem getting list of queue outbox. Skipping: {}", ex.getMessage(), ex);
|
||||
} finally {
|
||||
currentPrincipalResolver.pop();
|
||||
try {
|
||||
tenantScope.removeTempTenant(this.tenantEntityManager);
|
||||
} catch (InvalidApplicationException e) {
|
||||
logger.error( e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
|
|
|
@ -71,23 +71,14 @@ public class UserTouchedIntegrationEventHandlerImpl implements UserTouchedIntegr
|
|||
|
||||
EventProcessingStatus status = EventProcessingStatus.Success;
|
||||
try {
|
||||
if (this.tenantScope.isMultitenant() && properties.getTenantId() != null) {
|
||||
TenantEntity tenant = queryFactory.query(TenantQuery.class).disableTracking().ids(properties.getTenantId()).firstAs(new BaseFieldSet().ensure(Tenant._id).ensure(Tenant._code));
|
||||
if (tenant == null) {
|
||||
logger.error("missing tenant from event message");
|
||||
return EventProcessingStatus.Error;
|
||||
}
|
||||
this.tenantScope.setTempTenant(tenantEntityManager, properties.getTenantId(), tenant.getCode());
|
||||
} else if (this.tenantScope.isMultitenant()) {
|
||||
// logger.error("missing tenant from event message");
|
||||
// return EventProcessingStatus.Error;
|
||||
this.tenantScope.setTempTenant(tenantEntityManager, null, this.tenantScope.getDefaultTenantCode());
|
||||
}
|
||||
|
||||
currentPrincipalResolver.push(InboxPrincipal.build(properties, claimExtractorProperties));
|
||||
|
||||
userService.persist(event, null);
|
||||
|
||||
try {
|
||||
this.tenantEntityManager.disableTenantFilters();
|
||||
userService.persist(event, null);
|
||||
} finally {
|
||||
this.tenantEntityManager.reloadTenantFilters();
|
||||
}
|
||||
auditService.track(AuditableAction.User_Persist, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("model", event)
|
||||
));
|
||||
|
@ -97,11 +88,6 @@ public class UserTouchedIntegrationEventHandlerImpl implements UserTouchedIntegr
|
|||
logger.error("Problem getting list of queue outbox. Skipping: {}", ex.getMessage(), ex);
|
||||
} finally {
|
||||
currentPrincipalResolver.pop();
|
||||
try {
|
||||
tenantScope.removeTempTenant(this.tenantEntityManager);
|
||||
} catch (InvalidApplicationException e) {
|
||||
logger.error( e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
|
|
|
@ -88,7 +88,7 @@ public class UserServiceImpl implements UserService {
|
|||
public User persist(UserTouchedIntegrationEvent model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JsonProcessingException {
|
||||
logger.debug(new MapLogEntry("persisting user").And("model", model).And("fields", fields));
|
||||
|
||||
// this.authorizationService.authorizeAtLeastOneForce(model.getId() != null ? List.of(new OwnedResource(model.getId())) : null, Permission.EditUser);
|
||||
this.authorizationService.authorize(Permission.EditUser);
|
||||
|
||||
Boolean isValid = this.conventionService.isValidGuid(model.getId());
|
||||
|
||||
|
|
Loading…
Reference in New Issue