changed export-xml-permission for an invited user in a description template

This commit is contained in:
Sofia Papacharalampous 2024-07-02 14:37:46 +03:00
parent 1bacd7fc4a
commit 42a1fbf691
4 changed files with 15 additions and 7 deletions

View File

@ -869,7 +869,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
public DescriptionTemplateImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException { public DescriptionTemplateImportExport exportXmlEntity(UUID id, boolean ignoreAuthorize) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException {
logger.debug(new MapLogEntry("exportXml").And("id", id)); logger.debug(new MapLogEntry("exportXml").And("id", id));
if (!ignoreAuthorize) this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate); if (!ignoreAuthorize) this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionTemplateAffiliation(id)), Permission.ExportDescriptionTemplate);
DescriptionTemplateEntity data = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().ids(id).authorize(AuthorizationFlags.AllExceptPublic).first(); DescriptionTemplateEntity data = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().ids(id).authorize(AuthorizationFlags.AllExceptPublic).first();
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
@ -882,7 +882,8 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
public ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { public ResponseEntity<byte[]> exportXml(UUID id) throws MyForbiddenException, MyNotFoundException, JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException {
logger.debug(new MapLogEntry("exportXml").And("id", id)); logger.debug(new MapLogEntry("exportXml").And("id", id));
this.authorizationService.authorizeForce(Permission.ExportDescriptionTemplate); this.authorizationService.authorizeAtLeastOneForce(List.of(this.authorizationContentResolver.descriptionTemplateAffiliation(id)), Permission.ExportDescriptionTemplate);
DescriptionTemplateEntity data = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().ids(id).authorize(AuthorizationFlags.AllExceptPublic).first(); DescriptionTemplateEntity data = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking().ids(id).authorize(AuthorizationFlags.AllExceptPublic).first();
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale())); if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));

View File

@ -468,6 +468,9 @@ permissions:
- Admin - Admin
- TenantAdmin - TenantAdmin
- TenantPlanManager - TenantPlanManager
descriptionTemplate:
roles:
- Owner
claims: [ ] claims: [ ]
clients: [ ] clients: [ ]
allowAnonymous: false allowAnonymous: false

View File

@ -5,7 +5,7 @@
<div class="col"> <div class="col">
<app-navigation-breadcrumb /> <app-navigation-breadcrumb />
</div> </div>
<div class="col-auto"> <div class="col-auto" *ngIf="canCreateNew()">
<button mat-raised-button class="import-btn" (click)="import()"> <button mat-raised-button class="import-btn" (click)="import()">
<span class="button-text"> <span class="button-text">
{{'DESCRIPTION-TEMPLATE-LISTING.IMPORT.UPLOAD-XML' | translate}} {{'DESCRIPTION-TEMPLATE-LISTING.IMPORT.UPLOAD-XML' | translate}}

View File

@ -202,8 +202,12 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent<De
return descriptionTemplate.status !== DescriptionTemplateStatus.Finalized && this.hasPermission(AppPermission.EditDescriptionTemplate, descriptionTemplate); return descriptionTemplate.status !== DescriptionTemplateStatus.Finalized && this.hasPermission(AppPermission.EditDescriptionTemplate, descriptionTemplate);
} }
public canCreateNew(): boolean {
return this.hasExplicitPermission(AppPermission.EditDescriptionTemplate);
}
public canAddNewVersion(descriptionTemplate: DescriptionTemplate): boolean { public canAddNewVersion(descriptionTemplate: DescriptionTemplate): boolean {
return descriptionTemplate.belongsToCurrentTenant != false && this.hasExplicitPermission(AppPermission.EditDescriptionTemplate); return descriptionTemplate.belongsToCurrentTenant != false && this.canCreateNew();
} }
public canClone(descriptionTemplate: DescriptionTemplate): boolean { public canClone(descriptionTemplate: DescriptionTemplate): boolean {
@ -211,11 +215,11 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent<De
} }
public canViewVersions(descriptionTemplate: DescriptionTemplate): boolean { public canViewVersions(descriptionTemplate: DescriptionTemplate): boolean {
return descriptionTemplate.belongsToCurrentTenant != false && this.hasExplicitPermission(AppPermission.EditDescriptionTemplate); return descriptionTemplate.belongsToCurrentTenant != false && this.canCreateNew();
} }
public canDownloadXml(descriptionTemplate: DescriptionTemplate): boolean { public canDownloadXml(descriptionTemplate: DescriptionTemplate): boolean {
return descriptionTemplate.belongsToCurrentTenant != false && this.hasPermission(AppPermission.ExportDescriptionTemplate, descriptionTemplate); return descriptionTemplate.belongsToCurrentTenant != false;
} }
public canDelete(descriptionTemplate: DescriptionTemplate): boolean { public canDelete(descriptionTemplate: DescriptionTemplate): boolean {