uasage limit changes
This commit is contained in:
parent
c5fb1de856
commit
a172defde8
|
@ -18,6 +18,6 @@ public interface UsageLimitService {
|
|||
|
||||
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
||||
|
||||
void checkIncrease(UsageLimitTargetMetric metric);
|
||||
void checkIncrease(UsageLimitTargetMetric metric) throws InvalidApplicationException;
|
||||
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ public class UsageLimitServiceImpl implements UsageLimitService {
|
|||
this.deleterFactory.deleter(UsageLimitDeleter.class).deleteAndSaveByIds(List.of(id));
|
||||
}
|
||||
|
||||
public void checkIncrease(UsageLimitTargetMetric metric) {
|
||||
public void checkIncrease(UsageLimitTargetMetric metric) throws InvalidApplicationException {
|
||||
|
||||
if (usageLimitProperties.getEnabled() == null || !usageLimitProperties.getEnabled()) return;
|
||||
|
||||
|
@ -141,20 +141,14 @@ public class UsageLimitServiceImpl implements UsageLimitService {
|
|||
try {
|
||||
this.tenantEntityManager.loadExplicitTenantFilters();
|
||||
UsageLimitEntity usageLimitEntity = this.queryFactory.query(UsageLimitQuery.class).disableTracking().usageLimitTargetMetrics(metric).isActive(IsActive.Active).firstAs(new BaseFieldSet().ensure(UsageLimit._targetMetric).ensure(UsageLimit._value));
|
||||
if (usageLimitEntity != null && currentValue > usageLimitEntity.getValue()) throw new MyValidationException(this.errors.getUsageLimitException().getCode(), this.errors.getUsageLimitException().getMessage());
|
||||
if (usageLimitEntity != null && currentValue >= usageLimitEntity.getValue()) throw new MyValidationException(this.errors.getUsageLimitException().getCode(), this.errors.getUsageLimitException().getMessage());
|
||||
|
||||
} catch (InvalidApplicationException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new MyApplicationException(e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
this.tenantEntityManager.reloadTenantFilters();
|
||||
} catch (InvalidApplicationException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new MyApplicationException(e.getMessage());
|
||||
}
|
||||
this.tenantEntityManager.reloadTenantFilters();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue