tenant code validation

This commit is contained in:
Efstratios Giannopoulos 2024-05-17 12:02:00 +03:00
parent 30e5ed504a
commit 125fd2c994
5 changed files with 40 additions and 22 deletions

View File

@ -8,7 +8,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription systemError;
public ErrorDescription getSystemError() {
return systemError;
return this.systemError;
}
public void setSystemError(ErrorDescription systemError) {
@ -18,7 +18,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription forbidden;
public ErrorDescription getForbidden() {
return forbidden;
return this.forbidden;
}
public void setForbidden(ErrorDescription forbidden) {
@ -28,7 +28,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription hashConflict;
public ErrorDescription getHashConflict() {
return hashConflict;
return this.hashConflict;
}
public void setHashConflict(ErrorDescription hashConflict) {
@ -38,7 +38,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription modelValidation;
public ErrorDescription getModelValidation() {
return modelValidation;
return this.modelValidation;
}
public void setModelValidation(ErrorDescription modelValidation) {
@ -48,7 +48,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription descriptionTemplateNewVersionConflict;
public ErrorDescription getDescriptionTemplateNewVersionConflict() {
return descriptionTemplateNewVersionConflict;
return this.descriptionTemplateNewVersionConflict;
}
public void setDescriptionTemplateNewVersionConflict(ErrorDescription descriptionTemplateNewVersionConflict) {
@ -58,7 +58,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription dmpNewVersionConflict;
public ErrorDescription getDmpNewVersionConflict() {
return dmpNewVersionConflict;
return this.dmpNewVersionConflict;
}
public void setDmpNewVersionConflict(ErrorDescription dmpNewVersionConflict) {
@ -68,7 +68,7 @@ public class ErrorThesaurusProperties {
public ErrorDescription dmpBlueprintNewVersionConflict;
public ErrorDescription getDmpBlueprintNewVersionConflict() {
return dmpBlueprintNewVersionConflict;
return this.dmpBlueprintNewVersionConflict;
}
public void setDmpBlueprintNewVersionConflict(ErrorDescription dmpBlueprintNewVersionConflict) {
@ -78,7 +78,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription dmpIsFinalized;
public ErrorDescription getDmpIsFinalized() {
return dmpIsFinalized;
return this.dmpIsFinalized;
}
public void setDmpIsFinalized(ErrorDescription dmpIsFinalized) {
@ -88,7 +88,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription dmpCanNotChange;
public ErrorDescription getDmpCanNotChange() {
return dmpCanNotChange;
return this.dmpCanNotChange;
}
public void setDmpCanNotChange(ErrorDescription dmpCanNotChange) {
@ -98,7 +98,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription dmpDescriptionTemplateCanNotChange;
public ErrorDescription getDmpDescriptionTemplateCanNotChange() {
return dmpDescriptionTemplateCanNotChange;
return this.dmpDescriptionTemplateCanNotChange;
}
public void setDmpDescriptionTemplateCanNotChange(ErrorDescription dmpDescriptionTemplateCanNotChange) {
@ -108,7 +108,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription invalidDescriptionTemplate;
public ErrorDescription getInvalidDescriptionTemplate() {
return invalidDescriptionTemplate;
return this.invalidDescriptionTemplate;
}
public void setInvalidDescriptionTemplate(ErrorDescription invalidDescriptionTemplate) {
@ -118,7 +118,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription descriptionIsFinalized;
public ErrorDescription getDescriptionIsFinalized() {
return descriptionIsFinalized;
return this.descriptionIsFinalized;
}
public void setDescriptionIsFinalized(ErrorDescription descriptionIsFinalized) {
@ -128,7 +128,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription dmpBlueprintHasNoDescriptionTemplates;
public ErrorDescription getDmpBlueprintHasNoDescriptionTemplates() {
return dmpBlueprintHasNoDescriptionTemplates;
return this.dmpBlueprintHasNoDescriptionTemplates;
}
public void setDmpBlueprintHasNoDescriptionTemplates(ErrorDescription dmpBlueprintHasNoDescriptionTemplates) {
@ -138,7 +138,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription dmpDescriptionTemplateCanNotRemove;
public ErrorDescription getDmpDescriptionTemplateCanNotRemove() {
return dmpDescriptionTemplateCanNotRemove;
return this.dmpDescriptionTemplateCanNotRemove;
}
public void setDmpDescriptionTemplateCanNotRemove(ErrorDescription dmpDescriptionTemplateCanNotRemove) {
@ -148,7 +148,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription missingTenant;
public ErrorDescription getMissingTenant() {
return missingTenant;
return this.missingTenant;
}
public void setMissingTenant(ErrorDescription missingTenant) {
@ -158,7 +158,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription tenantNotAllowed;
public ErrorDescription getTenantNotAllowed() {
return tenantNotAllowed;
return this.tenantNotAllowed;
}
public void setTenantNotAllowed(ErrorDescription tenantNotAllowed) {
@ -168,7 +168,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription tenantTampering;
public ErrorDescription getTenantTampering() {
return tenantTampering;
return this.tenantTampering;
}
public void setTenantTampering(ErrorDescription tenantTampering) {
@ -178,7 +178,7 @@ public class ErrorThesaurusProperties {
private ErrorDescription tenantConfigurationTypeCanNotChange;
public ErrorDescription getTenantConfigurationTypeCanNotChange() {
return tenantConfigurationTypeCanNotChange;
return this.tenantConfigurationTypeCanNotChange;
}
public void setTenantConfigurationTypeCanNotChange(ErrorDescription tenantConfigurationTypeCanNotChange) {
@ -188,10 +188,20 @@ public class ErrorThesaurusProperties {
private ErrorDescription multipleTenantConfigurationTypeNotAllowed;
public ErrorDescription getMultipleTenantConfigurationTypeNotAllowed() {
return multipleTenantConfigurationTypeNotAllowed;
return this.multipleTenantConfigurationTypeNotAllowed;
}
public void setMultipleTenantConfigurationTypeNotAllowed(ErrorDescription multipleTenantConfigurationTypeNotAllowed) {
this.multipleTenantConfigurationTypeNotAllowed = multipleTenantConfigurationTypeNotAllowed;
}
private ErrorDescription tenantCodeExists;
public ErrorDescription getTenantCodeExists() {
return this.tenantCodeExists;
}
public void setTenantCodeExists(ErrorDescription tenantCodeExists) {
this.tenantCodeExists = tenantCodeExists;
}
}

View File

@ -142,6 +142,9 @@ public class TenantServiceImpl implements TenantService {
this.entityManager.flush();
Long tenantsWithThisCode = this.queryFactory.query(TenantQuery.class).codes(data.getCode()).count();
if (tenantsWithThisCode > 1) throw new MyValidationException(this.errors.getTenantCodeExists().getCode(), this.errors.getTenantCodeExists().getMessage());
if (!isUpdate) {
this.keycloakService.createTenantGroups(data.getCode());
this.autoAssignGlobalAdminsToNewTenant(data);

View File

@ -65,4 +65,6 @@ error-thesaurus:
multiple-tenant-configuration-type-not-allowed:
code: 125
message: Multiple Tenant Configuration Type Not Allowed
tenant-code-exists:
code: 126
message: Tenant code exists

View File

@ -16,5 +16,5 @@ export enum ResponseErrorCode {
TenantTampering = 123,
TenantConfigurationTypeCanNotChange = 124,
MultipleTenantConfigurationTypeNotAllowed = 125,
TenantCodeExists = 126,
}

View File

@ -139,6 +139,9 @@ export abstract class BaseEditor<EditorModelType extends BaseEditorModel, Entity
this.uiNotificationService.snackBarNotification(errorResponse.error.error, SnackBarNotificationLevel.Error);
this.refreshOnNavigateToData(null);
}
if(errorResponse.error.code === ResponseErrorCode.TenantCodeExists){
this.uiNotificationService.snackBarNotification(errorResponse.error.error, SnackBarNotificationLevel.Error);
}
else {
this.uiNotificationService.snackBarNotification(error.getMessagesString(), SnackBarNotificationLevel.Warning);
}