fixes
This commit is contained in:
parent
adacea4788
commit
feb6c5dee0
|
@ -69,7 +69,7 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes
|
|||
if (idsToResolve.isEmpty()) return affiliatedResources;
|
||||
List<PlanUserEntity> planUsers;
|
||||
try {
|
||||
this.tenantEntityManager.loadExplictTenantFilters();
|
||||
this.tenantEntityManager.loadExplicitTenantFilters();
|
||||
planUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking().planIds(ids).sectionIsEmpty(true).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(PlanUser._role).ensure(PlanUser._plan));
|
||||
} catch (InvalidApplicationException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
@ -109,7 +109,7 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes
|
|||
|
||||
List<UserDescriptionTemplateEntity> userDescriptionTemplates;
|
||||
try {
|
||||
this.tenantEntityManager.loadExplictTenantFilters();
|
||||
this.tenantEntityManager.loadExplicitTenantFilters();
|
||||
userDescriptionTemplates = this.queryFactory.query(UserDescriptionTemplateQuery.class).disableTracking().descriptionTemplateIds(ids).userIds(userId).isActive(IsActive.Active).collectAs(new BaseFieldSet().ensure(UserDescriptionTemplate._role).ensure(UserDescriptionTemplate._descriptionTemplate));
|
||||
} catch (InvalidApplicationException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
@ -139,7 +139,7 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes
|
|||
//TODO: investigate if we want to use cache
|
||||
boolean hasAny;
|
||||
try {
|
||||
this.tenantEntityManager.loadExplictTenantFilters();
|
||||
this.tenantEntityManager.loadExplicitTenantFilters();
|
||||
hasAny = this.queryFactory.query(UserDescriptionTemplateQuery.class).disableTracking().userIds(userId).isActive(IsActive.Active).count() > 0;
|
||||
} catch (InvalidApplicationException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
@ -176,7 +176,7 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes
|
|||
List<PlanUserEntity> planUsers;
|
||||
List<DescriptionEntity> descriptionEntities;
|
||||
try {
|
||||
this.tenantEntityManager.loadExplictTenantFilters();
|
||||
this.tenantEntityManager.loadExplicitTenantFilters();
|
||||
descriptionEntities = this.queryFactory.query(DescriptionQuery.class).disableTracking().ids(ids).collectAs(new BaseFieldSet().ensure(Description._id).ensure(Description._planDescriptionTemplate).ensure(Description._plan));
|
||||
planDescriptionTemplateEntities = this.queryFactory.query(PlanDescriptionTemplateQuery.class).disableTracking().ids(descriptionEntities.stream().map(DescriptionEntity::getPlanDescriptionTemplateId).distinct().toList()).collectAs(new BaseFieldSet().ensure(PlanDescriptionTemplate._id).ensure(PlanDescriptionTemplate._sectionId));
|
||||
planUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking().descriptionIds(ids).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(PlanUser._role).ensure(PlanUser._sectionId).ensure(PlanUser._plan));
|
||||
|
@ -232,7 +232,7 @@ public class AuthorizationContentResolverImpl implements AuthorizationContentRes
|
|||
|
||||
List<PlanUserEntity> planUsers;
|
||||
try {
|
||||
this.tenantEntityManager.loadExplictTenantFilters();
|
||||
this.tenantEntityManager.loadExplicitTenantFilters();
|
||||
planUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking().planIds(planId).userIds(userId).isActives(IsActive.Active).collectAs(new BaseFieldSet().ensure(PlanUser._role).ensure(PlanUser._sectionId).ensure(PlanUser._plan));
|
||||
} catch (InvalidApplicationException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
|
|
@ -114,7 +114,7 @@ public class TenantEntityManager {
|
|||
this.tenantFiltersDisabled = false;
|
||||
}
|
||||
|
||||
public void loadExplictTenantFilters() throws InvalidApplicationException {
|
||||
public void loadExplicitTenantFilters() throws InvalidApplicationException {
|
||||
if (!this.entityManager.isOpen()) return;
|
||||
|
||||
this.disableTenantFilters();
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package org.opencdmp.service.accounting;
|
||||
|
||||
public class AccountingService {
|
||||
|
||||
private Integer getCurrentMetricValue(String metric) {
|
||||
return 10;
|
||||
}
|
||||
|
||||
private void set(String metric) {
|
||||
//Get/Calculate current metric value
|
||||
//Find metric value from db
|
||||
// compare these two and throw UsageLimitException when current > metric value
|
||||
}
|
||||
|
||||
private void increase(String metric) {
|
||||
//Get/Calculate current metric value
|
||||
//Find metric value from db
|
||||
// compare these two and throw UsageLimitException when current > metric value
|
||||
}
|
||||
|
||||
private void decrease(String metric) {
|
||||
//Get/Calculate current metric value
|
||||
//Find metric value from db
|
||||
// compare these two and throw UsageLimitException when current > metric value
|
||||
}
|
||||
}
|
|
@ -222,6 +222,8 @@ public class DescriptionServiceImpl implements DescriptionService {
|
|||
if (!data.getPlanId().equals(model.getPlanId())) throw new MyValidationException(this.errors.getPlanCanNotChange().getCode(), this.errors.getPlanCanNotChange().getMessage());
|
||||
if (!data.getPlanDescriptionTemplateId().equals(model.getPlanDescriptionTemplateId())) throw new MyValidationException(this.errors.getPlanDescriptionTemplateCanNotChange().getCode(), this.errors.getPlanDescriptionTemplateCanNotChange().getMessage());
|
||||
} else {
|
||||
//this.usageLimitService.checkIncrease("description_count");
|
||||
|
||||
PlanEntity planEntity = this.entityManager.find(PlanEntity.class, model.getPlanId(), true);
|
||||
if (planEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getPlanId(), Plan.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package org.opencdmp.service.usagelimit;
|
||||
|
||||
public class UsageLimitService {
|
||||
|
||||
private void checkIncrease(String metric) {
|
||||
//Get/Calculate current metric value from accountingService
|
||||
//Find metric value from db
|
||||
// compare these two and throw UsageLimitException when current > metric value
|
||||
}
|
||||
|
||||
}
|
|
@ -326,7 +326,9 @@ public class UserServiceImpl implements UserService {
|
|||
@Override
|
||||
public User patchRoles(UserRolePatchPersist model, FieldSet fields) throws InvalidApplicationException {
|
||||
logger.debug(new MapLogEntry("persisting data UserRole").And("model", model).And("fields", fields));
|
||||
this.authorizationService.authorizeAtLeastOneForce(this.userScope.getUserId() != null ? List.of(new OwnedResource(this.userScope.getUserId())) : null, Permission.EditUser, Permission.EditTenantUserRole);
|
||||
|
||||
if (!model.getHasTenantAdminMode()) this.authorizationService.authorizeForce(Permission.EditUser);
|
||||
else this.authorizationService.authorizeForce(Permission.EditTenantUserRole);
|
||||
|
||||
UserEntity data = this.entityManager.find(UserEntity.class, model.getId(), true);
|
||||
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), User.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
|
Loading…
Reference in New Issue