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) {
|
public void setUsageLimitException(ErrorDescription usageLimitException) {
|
||||||
this.usageLimitException = 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);
|
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());
|
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
|
||||||
|
|
||||||
UsageLimitEntity data;
|
UsageLimitEntity data;
|
||||||
|
|
|
@ -124,4 +124,7 @@ error-thesaurus:
|
||||||
message: Max descriptions exceeded for this plan
|
message: Max descriptions exceeded for this plan
|
||||||
usageLimitException:
|
usageLimitException:
|
||||||
code: 145
|
code: 145
|
||||||
message: Usage limit exception for this target metric
|
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,
|
RequestHasExpired = 143,
|
||||||
MaxDescriptionsExceeded = 144,
|
MaxDescriptionsExceeded = 144,
|
||||||
UsageLimitException = 145,
|
UsageLimitException = 145,
|
||||||
|
UsageLimitMetricAlreadyExists = 146,
|
||||||
|
|
||||||
// Notification & Annotation Errors
|
// Notification & Annotation Errors
|
||||||
InvalidApiKey = 200,
|
InvalidApiKey = 200,
|
||||||
|
@ -157,6 +158,8 @@ export class ResponseErrorCodeHelper {
|
||||||
return language.instant("GENERAL.BACKEND-ERRORS.MAX-DESCRIPTION-EXCEEDED");
|
return language.instant("GENERAL.BACKEND-ERRORS.MAX-DESCRIPTION-EXCEEDED");
|
||||||
case ResponseErrorCode.UsageLimitException:
|
case ResponseErrorCode.UsageLimitException:
|
||||||
return language.instant("GENERAL.BACKEND-ERRORS.USAGE-LIMIT-EXCEPTION");
|
return language.instant("GENERAL.BACKEND-ERRORS.USAGE-LIMIT-EXCEPTION");
|
||||||
|
case ResponseErrorCode.UsageLimitMetricAlreadyExists:
|
||||||
|
return language.instant("GENERAL.BACKEND-ERRORS.USAGE-LIMIT-METRIC-ALLREADY-EXISTS");
|
||||||
default:
|
default:
|
||||||
return language.instant("GENERAL.SNACK-BAR.NOT-FOUND");
|
return language.instant("GENERAL.SNACK-BAR.NOT-FOUND");
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
"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": {
|
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||||
"WARNING": "Kontuz!",
|
"WARNING": "Kontuz!",
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
"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": {
|
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||||
"WARNING": "Warnung!",
|
"WARNING": "Warnung!",
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
"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": {
|
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||||
"WARNING": "Warning!",
|
"WARNING": "Warning!",
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
"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": {
|
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||||
"WARNING": "Atención!",
|
"WARNING": "Atención!",
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
"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": {
|
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||||
"WARNING": "Προσοχή!",
|
"WARNING": "Προσοχή!",
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
"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": {
|
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||||
"WARNING": "Oprez!",
|
"WARNING": "Oprez!",
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
"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": {
|
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||||
"WARNING": "Ostrzeżenie!",
|
"WARNING": "Ostrzeżenie!",
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
"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": {
|
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||||
"WARNING": "Atenção!",
|
"WARNING": "Atenção!",
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
"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": {
|
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||||
"WARNING": "Upozornenie!",
|
"WARNING": "Upozornenie!",
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
"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": {
|
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||||
"WARNING": "Oprez!",
|
"WARNING": "Oprez!",
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
"INVITE-USER-ALREADY-CONFIRMED": "Ιnvitation has already confirmed",
|
||||||
"REQUEST-HAS-EXPIRED": "Request has expired",
|
"REQUEST-HAS-EXPIRED": "Request has expired",
|
||||||
"MAX-DESCRIPTION-EXCEEDED": "This plan has reached the maximun descriptions for this description template",
|
"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": {
|
"FORM-VALIDATION-DISPLAY-DIALOG": {
|
||||||
"WARNING": "Uyarı!",
|
"WARNING": "Uyarı!",
|
||||||
|
|
Loading…
Reference in New Issue