diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java index fe41debe1..bac784ee5 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/dmpblueprint/DmpBlueprintServiceImpl.java @@ -5,6 +5,7 @@ import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.Permission; import eu.eudat.commons.XmlHandlingService; import eu.eudat.commons.enums.*; +import eu.eudat.commons.scope.tenant.TenantScope; import eu.eudat.commons.types.dmpblueprint.*; import eu.eudat.commons.types.dmpblueprint.importexport.*; import eu.eudat.convention.ConventionService; @@ -51,10 +52,7 @@ import javax.xml.transform.TransformerException; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.time.Instant; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.UUID; +import java.util.*; @Service public class DmpBlueprintServiceImpl implements DmpBlueprintService { @@ -82,19 +80,19 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { private final ErrorThesaurusProperties errors; private final ValidatorFactory validatorFactory; - + private final TenantScope tenantScope; @Autowired public DmpBlueprintServiceImpl( - TenantEntityManager entityManager, - AuthorizationService authorizationService, - DeleterFactory deleterFactory, - BuilderFactory builderFactory, - ConventionService conventionService, - MessageSource messageSource, QueryFactory queryFactory, - ResponseUtilsService responseUtilsService, - XmlHandlingService xmlHandlingService, - ErrorThesaurusProperties errors, - ValidatorFactory validatorFactory) { + TenantEntityManager entityManager, + AuthorizationService authorizationService, + DeleterFactory deleterFactory, + BuilderFactory builderFactory, + ConventionService conventionService, + MessageSource messageSource, QueryFactory queryFactory, + ResponseUtilsService responseUtilsService, + XmlHandlingService xmlHandlingService, + ErrorThesaurusProperties errors, + ValidatorFactory validatorFactory, TenantScope tenantScope) { this.entityManager = entityManager; this.authorizationService = authorizationService; this.deleterFactory = deleterFactory; @@ -106,6 +104,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { this.xmlHandlingService = xmlHandlingService; this.errors = errors; this.validatorFactory = validatorFactory; + this.tenantScope = tenantScope; } //region Persist @@ -394,6 +393,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService { throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (!this.conventionService.hashValue(oldDmpBlueprintEntity.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage()); + if (!this.tenantScope.isSet() || !Objects.equals(oldDmpBlueprintEntity.getTenantId(), this.tenantScope.getTenant())) throw new MyForbiddenException(this.errors.getTenantTampering().getCode(), this.errors.getTenantTampering().getMessage()); List latestVersionDmpBlueprints = this.queryFactory.query(DmpBlueprintQuery.class) .versionStatuses(DmpBlueprintVersionStatus.Current) diff --git a/dmp-frontend/src/app/core/model/lock/lock.model.ts b/dmp-frontend/src/app/core/model/lock/lock.model.ts index 5dd1e8f68..8c0c84ae7 100644 --- a/dmp-frontend/src/app/core/model/lock/lock.model.ts +++ b/dmp-frontend/src/app/core/model/lock/lock.model.ts @@ -10,6 +10,7 @@ export interface Lock { lockedBy: User; lockedAt: Date; touchedAt: Date; + belongsToCurrentTenant?: boolean; hash: String; } diff --git a/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.html b/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.html index 4ed9b6a9d..ad6a9b84e 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.html @@ -98,7 +98,7 @@ - - @@ -119,4 +119,4 @@ - \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts b/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts index 69773ebf1..ad0352583 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts @@ -57,6 +57,7 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent(x => x.updatedAt), nameof(x => x.createdAt), nameof(x => x.hash), + nameof(x => x.belongsToCurrentTenant), nameof(x => x.isActive) ]; diff --git a/dmp-frontend/src/app/ui/admin/description-types/editor/description-template-type-editor.component.ts b/dmp-frontend/src/app/ui/admin/description-types/editor/description-template-type-editor.component.ts index bbcb0194e..54003d566 100644 --- a/dmp-frontend/src/app/ui/admin/description-types/editor/description-template-type-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-types/editor/description-template-type-editor.component.ts @@ -40,17 +40,17 @@ export class DescriptionTemplateTypeEditorComponent extends BaseEditor edit{{'DESCRIPTION-TEMPLATE-TYPE-LISTING.ACTIONS.EDIT' | translate}} - @@ -106,4 +106,4 @@ - \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/description-types/listing/description-template-type-listing.component.ts b/dmp-frontend/src/app/ui/admin/description-types/listing/description-template-type-listing.component.ts index fc891de59..198818fa2 100644 --- a/dmp-frontend/src/app/ui/admin/description-types/listing/description-template-type-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-types/listing/description-template-type-listing.component.ts @@ -45,6 +45,7 @@ export class DescriptionTemplateTypeListingComponent extends BaseListingComponen nameof(x => x.updatedAt), nameof(x => x.createdAt), nameof(x => x.hash), + nameof(x => x.belongsToCurrentTenant), nameof(x => x.isActive) ]; diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html index bd8dae266..a6954e909 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/editor/dmp-blueprint-editor.component.html @@ -14,7 +14,7 @@ {{formGroup.get('label').value}} -
+
- +
{{'DMP-BLUEPRINT-EDITOR.FIELDS.CATEGORY' | translate}} @@ -237,8 +237,8 @@
{{descriptionTemplateIndex + 1}} drag_indicator -
- +
+
@@ -283,7 +283,7 @@
-
+
{{section.get('descriptionTemplates').getError('backendError').message}}
diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/listing/dmp-blueprint-listing.component.html b/dmp-frontend/src/app/ui/admin/dmp-blueprint/listing/dmp-blueprint-listing.component.html index fc68bb314..11aadb161 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/listing/dmp-blueprint-listing.component.html +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/listing/dmp-blueprint-listing.component.html @@ -33,7 +33,7 @@ download --> - + @@ -94,7 +94,7 @@ - - @@ -115,4 +115,4 @@ - \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/dmp-blueprint/listing/dmp-blueprint-listing.component.ts b/dmp-frontend/src/app/ui/admin/dmp-blueprint/listing/dmp-blueprint-listing.component.ts index 2c8ff00a3..06e26b843 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-blueprint/listing/dmp-blueprint-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-blueprint/listing/dmp-blueprint-listing.component.ts @@ -56,7 +56,8 @@ export class DmpBlueprintListingComponent extends BaseListingComponent(x => x.updatedAt), nameof(x => x.createdAt), nameof(x => x.hash), - nameof(x => x.isActive) + nameof(x => x.isActive), + nameof(x => x.belongsToCurrentTenant) ]; rowIdentity = x => x.id; @@ -114,7 +115,7 @@ export class DmpBlueprintListingComponent extends BaseListingComponent(x => x.label), sortable: true, languageName: 'DMP-BLUEPRINT-LISTING.FIELDS.NAME' - }, + }, { prop: nameof(x => x.status), sortable: true, diff --git a/dmp-frontend/src/app/ui/admin/entity-locks/lock-listing.component.html b/dmp-frontend/src/app/ui/admin/entity-locks/lock-listing.component.html index 926da068e..a8b7e5a6e 100644 --- a/dmp-frontend/src/app/ui/admin/entity-locks/lock-listing.component.html +++ b/dmp-frontend/src/app/ui/admin/entity-locks/lock-listing.component.html @@ -12,7 +12,7 @@ @@ -69,18 +69,18 @@
--> - + -
+
- +
- \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/entity-locks/lock-listing.component.ts b/dmp-frontend/src/app/ui/admin/entity-locks/lock-listing.component.ts index be5848d83..6f96ee9e1 100644 --- a/dmp-frontend/src/app/ui/admin/entity-locks/lock-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/entity-locks/lock-listing.component.ts @@ -43,6 +43,7 @@ export class LockListingComponent extends BaseListingComponent [nameof(x => x.lockedBy), nameof(x => x.name)].join('.'), nameof(x => x.lockedAt), nameof(x => x.touchedAt), + nameof(x => x.belongsToCurrentTenant), nameof(x => x.hash), ]; @@ -96,7 +97,7 @@ export class LockListingComponent extends BaseListingComponent sortable: true, languageName: 'LOCK-LISTING.FIELDS.TARGET-TYPE', pipe: this.pipeService.getPipe(LockTargetTypePipe) - }, + }, { prop: nameof(x => x.lockedBy.name), sortable: true, diff --git a/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.html b/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.html index 484c36ca8..9c490b8ec 100644 --- a/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.html @@ -9,7 +9,7 @@
-
+
diff --git a/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.ts b/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.ts index 94c975644..40bd16c1a 100644 --- a/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/language/editor/language-editor.component.ts @@ -53,7 +53,7 @@ export class LanguageEditorComponent extends BaseEditor edit{{'LANGUAGE-LISTING.ACTIONS.EDIT' | translate}} -
-
\ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/language/listing/language-listing.component.ts b/dmp-frontend/src/app/ui/admin/language/listing/language-listing.component.ts index 9534c8dde..b847a371f 100644 --- a/dmp-frontend/src/app/ui/admin/language/listing/language-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/language/listing/language-listing.component.ts @@ -42,6 +42,7 @@ export class LanguageListingComponent extends BaseListingComponent(x => x.updatedAt), nameof(x => x.createdAt), nameof(x => x.hash), + nameof(x => x.belongsToCurrentTenant), nameof(x => x.isActive) ]; diff --git a/dmp-frontend/src/app/ui/admin/prefilling-source/editor/prefilling-source-editor.component.ts b/dmp-frontend/src/app/ui/admin/prefilling-source/editor/prefilling-source-editor.component.ts index 71ba96253..1d2ae2f52 100644 --- a/dmp-frontend/src/app/ui/admin/prefilling-source/editor/prefilling-source-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/prefilling-source/editor/prefilling-source-editor.component.ts @@ -45,11 +45,11 @@ export class PrefillingSourceEditorComponent extends BaseEditor edit{{'PREFILLING-SOURCE-LISTING.ACTIONS.EDIT' | translate}} - - \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/prefilling-source/listing/prefilling-source-listing.component.ts b/dmp-frontend/src/app/ui/admin/prefilling-source/listing/prefilling-source-listing.component.ts index 42f221f73..3f23fae68 100644 --- a/dmp-frontend/src/app/ui/admin/prefilling-source/listing/prefilling-source-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/prefilling-source/listing/prefilling-source-listing.component.ts @@ -42,6 +42,7 @@ export class PrefillingSourceListingComponent extends BaseListingComponent(x => x.updatedAt), nameof(x => x.createdAt), nameof(x => x.hash), + nameof(x => x.belongsToCurrentTenant), nameof(x => x.isActive) ]; diff --git a/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.component.ts b/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.component.ts index 3041605b0..4ea892d15 100644 --- a/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/reference-type/editor/reference-type-editor.component.ts @@ -53,11 +53,11 @@ export class ReferenceTypeEditorComponent extends BaseEditor = new Map(); protected get canDelete(): boolean { - return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeleteReferenceType); + return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeleteReferenceType) && this.editorModel.belongsToCurrentTenant != false; } protected get canSave(): boolean { - return !this.isDeleted && this.hasPermission(this.authService.permissionEnum.EditReferenceType); + return !this.isDeleted && this.hasPermission(this.authService.permissionEnum.EditReferenceType) && this.editorModel.belongsToCurrentTenant != false; } protected get canFinalize(): boolean { @@ -229,7 +229,7 @@ export class ReferenceTypeEditorComponent extends BaseEditor{{'REFERENCE-TYPE-LISTING.TITLE' | translate}} - +
- @@ -109,4 +109,4 @@
- \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/reference-type/listing/reference-type-listing.component.ts b/dmp-frontend/src/app/ui/admin/reference-type/listing/reference-type-listing.component.ts index f39438e5c..26c280826 100644 --- a/dmp-frontend/src/app/ui/admin/reference-type/listing/reference-type-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/reference-type/listing/reference-type-listing.component.ts @@ -43,6 +43,7 @@ export class ReferenceTypeListingComponent extends BaseListingComponent(x => x.code), nameof(x => x.updatedAt), nameof(x => x.createdAt), + nameof(x => x.belongsToCurrentTenant), nameof(x => x.isActive) ]; @@ -91,7 +92,7 @@ export class ReferenceTypeListingComponent extends BaseListingComponent(x => x.name), sortable: true, languageName: 'REFERENCE-TYPE-LISTING.FIELDS.NAME' - }, + }, { prop: nameof(x => x.code), sortable: true, diff --git a/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.component.html b/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.component.html index 974f05ed3..7622b915c 100644 --- a/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.component.html +++ b/dmp-frontend/src/app/ui/admin/reference/editor/reference-editor.component.html @@ -9,7 +9,7 @@
-
+
-
- \ No newline at end of file + diff --git a/dmp-frontend/src/app/ui/admin/reference/listing/reference-listing.component.ts b/dmp-frontend/src/app/ui/admin/reference/listing/reference-listing.component.ts index 90b09195c..2ada3db7a 100644 --- a/dmp-frontend/src/app/ui/admin/reference/listing/reference-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/reference/listing/reference-listing.component.ts @@ -46,6 +46,7 @@ export class ReferenceListingComponent extends BaseListingComponent(x => x.updatedAt), nameof(x => x.createdAt), nameof(x => x.hash), + nameof(x => x.belongsToCurrentTenant), nameof(x => x.isActive) ]; @@ -94,7 +95,7 @@ export class ReferenceListingComponent extends BaseListingComponent(x => x.label), sortable: true, languageName: 'REFERENCE-LISTING.FIELDS.LABEL' - }, + }, { prop: nameof(x => x.source), sortable: true, diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts index 74e07f42f..f75c42077 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts @@ -200,10 +200,10 @@ export class DescriptionEditorComponent extends BaseEditor x.sectionId == sectionId && x.descriptionTemplateGroupId == result.descriptionTemplate.groupId); - + result.dmpDescriptionTemplate = this.item.dmp.dmpDescriptionTemplates.find(x => x.sectionId == sectionId && x.descriptionTemplateGroupId == result.descriptionTemplate.groupId); + this.prepareForm(result); // this.descriptionModel = this.descriptionModel.fromModel(result); // this.descriptionModel.dmp = data; @@ -549,6 +549,9 @@ export class DescriptionEditorComponent extends BaseEditor