add validation for duplicate usage limit metric in one tenant
This commit is contained in:
parent
79acc134f9
commit
e178116434
|
@ -398,4 +398,14 @@ public class ErrorThesaurusProperties {
|
|||
public void setUsageLimitException(ErrorDescription usageLimitException) {
|
||||
this.usageLimitException = usageLimitException;
|
||||
}
|
||||
|
||||
private ErrorDescription usageLimitMetricAlreadyExists;
|
||||
|
||||
public ErrorDescription getUsageLimitMetricAlreadyExists() {
|
||||
return usageLimitMetricAlreadyExists;
|
||||
}
|
||||
|
||||
public void setUsageLimitMetricAlreadyExists(ErrorDescription usageLimitMetricAlreadyExists) {
|
||||
this.usageLimitMetricAlreadyExists = usageLimitMetricAlreadyExists;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,6 +95,18 @@ public class UsageLimitServiceImpl implements UsageLimitService {
|
|||
|
||||
this.authorizationService.authorizeForce(Permission.EditUsageLimit);
|
||||
|
||||
try {
|
||||
this.tenantEntityManager.loadExplicitTenantFilters();
|
||||
UsageLimitQuery query = this.queryFactory.query(UsageLimitQuery.class).disableTracking().usageLimitTargetMetrics(model.getTargetMetric()).isActive(IsActive.Active);
|
||||
if (query != null && query.count() > 0) throw new MyValidationException(this.errors.getUsageLimitMetricAlreadyExists().getCode(), this.errors.getUsageLimitMetricAlreadyExists().getMessage());
|
||||
|
||||
} catch (InvalidApplicationException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new MyApplicationException(e.getMessage());
|
||||
} finally {
|
||||
this.tenantEntityManager.reloadTenantFilters();
|
||||
}
|
||||
|
||||
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
|
||||
|
||||
UsageLimitEntity data;
|
||||
|
|
|
@ -125,3 +125,6 @@ error-thesaurus:
|
|||
usageLimitException:
|
||||
code: 145
|
||||
message: Usage limit exception for this target metric
|
||||
usageLimitMetricAlreadyExists:
|
||||
code: 146
|
||||
message: Usage limit metric is already selected as target
|
|
@ -41,6 +41,7 @@ export enum ResponseErrorCode {
|
|||
RequestHasExpired = 143,
|
||||
MaxDescriptionsExceeded = 144,
|
||||
UsageLimitException = 145,
|
||||
UsageLimitMetricAlreadyExists = 146,
|
||||
|
||||
// Notification & Annotation Errors
|
||||
InvalidApiKey = 200,
|
||||
|
@ -157,6 +158,8 @@ export class ResponseErrorCodeHelper {
|
|||
return language.instant("GENERAL.BACKEND-ERRORS.MAX-DESCRIPTION-EXCEEDED");
|
||||
case ResponseErrorCode.UsageLimitException:
|
||||
return language.instant("GENERAL.BACKEND-ERRORS.USAGE-LIMIT-EXCEPTION");
|
||||
case ResponseErrorCode.UsageLimitMetricAlreadyExists:
|
||||
return language.instant("GENERAL.BACKEND-ERRORS.USAGE-LIMIT-METRIC-ALLREADY-EXISTS");
|
||||
default:
|
||||
return language.instant("GENERAL.SNACK-BAR.NOT-FOUND");
|
||||
}
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator."
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.",
|
||||
"USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant."
|
||||
},
|
||||
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||
"WARNING": "Kontuz!",
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator."
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.",
|
||||
"USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant."
|
||||
},
|
||||
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||
"WARNING": "Warnung!",
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator."
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.",
|
||||
"USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant."
|
||||
},
|
||||
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||
"WARNING": "Warning!",
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator."
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.",
|
||||
"USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant."
|
||||
},
|
||||
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||
"WARNING": "Atención!",
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator."
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.",
|
||||
"USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant."
|
||||
},
|
||||
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||
"WARNING": "Προσοχή!",
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator."
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.",
|
||||
"USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant."
|
||||
},
|
||||
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||
"WARNING": "Oprez!",
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator."
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.",
|
||||
"USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant."
|
||||
},
|
||||
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||
"WARNING": "Ostrzeżenie!",
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator."
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.",
|
||||
"USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant."
|
||||
},
|
||||
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||
"WARNING": "Atenção!",
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator."
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.",
|
||||
"USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant."
|
||||
},
|
||||
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||
"WARNING": "Upozornenie!",
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator."
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.",
|
||||
"USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant."
|
||||
},
|
||||
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||
"WARNING": "Oprez!",
|
||||
|
|
|
@ -80,7 +80,8 @@
|
|||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator."
|
||||
"USAGE-LIMIT-EXCEPTION": "Υou have exceeded the {{usageLimitLabel}} usage limit. Please contact your administrator.",
|
||||
"USAGE-LIMIT-METRIC-ALLREADY-EXISTS": "This usage limit metric is already defined in this tenant. Change metric or select other tenant."
|
||||
},
|
||||
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||
"WARNING": "Uyarı!",
|
||||
|
|
Loading…
Reference in New Issue