diff --git a/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java b/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java index ddd3ab82c..780008ce6 100644 --- a/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java +++ b/backend/core/src/main/java/org/opencdmp/errorcode/ErrorThesaurusProperties.java @@ -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; + } } diff --git a/backend/core/src/main/java/org/opencdmp/service/tenant/TenantServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/tenant/TenantServiceImpl.java index 67a0205d5..e8dba3eed 100644 --- a/backend/core/src/main/java/org/opencdmp/service/tenant/TenantServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/tenant/TenantServiceImpl.java @@ -141,6 +141,9 @@ public class TenantServiceImpl implements TenantService { else this.entityManager.persist(data); 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()); diff --git a/backend/web/src/main/resources/config/errors.yml b/backend/web/src/main/resources/config/errors.yml index 284314b61..9409cad3c 100644 --- a/backend/web/src/main/resources/config/errors.yml +++ b/backend/web/src/main/resources/config/errors.yml @@ -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 \ No newline at end of file diff --git a/dmp-frontend/src/app/core/common/enum/respone-error-code.ts b/dmp-frontend/src/app/core/common/enum/respone-error-code.ts index acbf1515a..bf367108d 100644 --- a/dmp-frontend/src/app/core/common/enum/respone-error-code.ts +++ b/dmp-frontend/src/app/core/common/enum/respone-error-code.ts @@ -16,5 +16,5 @@ export enum ResponseErrorCode { TenantTampering = 123, TenantConfigurationTypeCanNotChange = 124, MultipleTenantConfigurationTypeNotAllowed = 125, - + TenantCodeExists = 126, } diff --git a/dmp-frontend/src/common/base/base-editor.ts b/dmp-frontend/src/common/base/base-editor.ts index 17d501e49..d16932a00 100644 --- a/dmp-frontend/src/common/base/base-editor.ts +++ b/dmp-frontend/src/common/base/base-editor.ts @@ -138,7 +138,10 @@ export abstract class BaseEditor