From 6afb81b9ea173a2193d6d684ba1a2d86fc5f722e Mon Sep 17 00:00:00 2001 From: RIHTARSIC Joze <joze.rihtarsic@ext.ec.europa.eu> Date: Sun, 9 Jun 2024 18:09:53 +0200 Subject: [PATCH] Fix the PR comments --- .../property-details-dialog.component.ts | 50 ++++++++++++------- .../app/common/enums/property-type.enum.ts | 2 +- .../resource-dialog.component.ts | 1 - .../domain-properties-panel.component.html | 4 +- .../domain-properties-panel.component.ts | 4 +- .../smp/config/enums/SMPPropertyEnum.java | 2 +- .../DBDomainConfToDomainPropROConverter.java | 2 +- .../smp/services/ConfigurationService.java | 2 +- .../services/DomainSMLIntegrationService.java | 6 +-- .../smp/services/ui/UIDomainAdminService.java | 7 +-- .../smp/services/ui/UIDomainEditService.java | 14 +++++- .../smp/ui/edit/DomainEditController.java | 8 +-- .../ui/internal/DomainAdminController.java | 6 +-- 13 files changed, 65 insertions(+), 43 deletions(-) diff --git a/smp-angular/src/app/common/dialogs/property-details-dialog/property-details-dialog.component.ts b/smp-angular/src/app/common/dialogs/property-details-dialog/property-details-dialog.component.ts index c697f0a4e..c71953731 100644 --- a/smp-angular/src/app/common/dialogs/property-details-dialog/property-details-dialog.component.ts +++ b/smp-angular/src/app/common/dialogs/property-details-dialog/property-details-dialog.component.ts @@ -1,11 +1,23 @@ import {Component, Inject, OnInit} from '@angular/core'; -import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material/dialog'; -import {UntypedFormBuilder, UntypedFormControl, UntypedFormGroup} from "@angular/forms";; -import {AlertMessageService} from "../../../common/alert-message/alert-message.service"; +import { + MAT_DIALOG_DATA, + MatDialog, + MatDialogRef +} from '@angular/material/dialog'; +import { + UntypedFormBuilder, + UntypedFormControl, + UntypedFormGroup +} from "@angular/forms"; +import { + AlertMessageService +} from "../../../common/alert-message/alert-message.service"; import {EntityStatus} from "../../../common/enums/entity-status.enum"; import {SmpConstants} from "../../../smp.constants"; import {HttpClient} from "@angular/common/http"; -import {HttpErrorHandlerService} from "../../../common/error/http-error-handler.service"; +import { + HttpErrorHandlerService +} from "../../../common/error/http-error-handler.service"; import { PropertyRo } from "../../../system-settings/admin-properties/property-ro.model"; @@ -23,7 +35,7 @@ import {firstValueFrom} from "rxjs"; export class PropertyDetailsDialogComponent implements OnInit { static readonly NEW_MODE: string = 'New {TYPE} Property'; - static readonly EDIT_MODE: string = '{TYPE} Property Edit'; + static readonly EDIT_MODE: string = '{TYPE} Property Edit'; editMode: boolean; @@ -46,13 +58,13 @@ export class PropertyDetailsDialogComponent implements OnInit { this.editMode = data.edit; this.propertyType = data.propertyType; - this.propertyType = !data.propertyType?PropertyTypeEnum.SYSTEM: data.propertyType; + this.propertyType = !data.propertyType ? PropertyTypeEnum.SYSTEM : data.propertyType; this.formTitle = (this.editMode ? PropertyDetailsDialogComponent.EDIT_MODE : PropertyDetailsDialogComponent.NEW_MODE) .replace('{TYPE}', this.capitalize(this.propertyType)); this.current = this.editMode ? { - ...data.row , + ...data.row, } : { property: '', @@ -71,8 +83,7 @@ export class PropertyDetailsDialogComponent implements OnInit { 'value': new UntypedFormControl({value: ''}), 'valuePattern': new UntypedFormControl({value: ''}), 'errorMessage': new UntypedFormControl({value: ''}), - 'systemDefault': new UntypedFormControl({value: 'true' }), - + 'systemDefault': new UntypedFormControl({value: 'true'}), }); this.propertyForm.controls['property'].setValue(this.current.property); @@ -82,8 +93,8 @@ export class PropertyDetailsDialogComponent implements OnInit { this.propertyForm.controls['valuePattern'].setValue(this.current.valuePattern); this.propertyForm.controls['systemDefault'].setValue(this.current.systemDefault); - this.propertyForm.controls['errorMessage'].setValue('') - this.updateValueState() + this.propertyForm.controls['errorMessage'].setValue(''); + this.updateValueState(); } ngOnInit() { @@ -97,7 +108,7 @@ export class PropertyDetailsDialogComponent implements OnInit { async submitForm() { this.checkValidity(this.propertyForm); - let request: PropertyRo = this.getCurrent(); + let request: PropertyRo = this.getCurrent(); // if domain property we do not need to validate if (this.propertyType == PropertyTypeEnum.DOMAIN) { @@ -117,14 +128,14 @@ export class PropertyDetailsDialogComponent implements OnInit { const result: PropertyValidationRo = await firstValueFrom(validationObservable); this.showSpinner = false; if (!result.propertyValid) { - this.propertyForm.controls['errorMessage'].setValue(result.errorMessage?result.errorMessage:'Invalid property'); + this.propertyForm.controls['errorMessage'].setValue(result.errorMessage ? result.errorMessage : 'Invalid property'); } else { this.propertyForm.controls['errorMessage'].setValue(""); // we can close the dialog this.closeDialog(); } - } catch(err) { - if (this.httpErrorHandlerService.logoutOnInvalidSessionError(err)){ + } catch (err) { + if (this.httpErrorHandlerService.logoutOnInvalidSessionError(err)) { this.closeDialog(); return; } @@ -192,6 +203,7 @@ export class PropertyDetailsDialogComponent implements OnInit { return 'text'; } } + getInputPatternType(propertyType: string) { console.log("Get input pattern for row " + this.current.type) switch (propertyType) { @@ -217,7 +229,7 @@ export class PropertyDetailsDialogComponent implements OnInit { } public getCurrent(): PropertyRo { - this.current.status= EntityStatus.UPDATED; + this.current.status = EntityStatus.UPDATED; this.current.value = this.propertyForm.value['value']; this.current.systemDefault = this.propertyForm.value['systemDefault']; return this.current; @@ -229,14 +241,14 @@ export class PropertyDetailsDialogComponent implements OnInit { get isSystemDefault(): boolean { let systemDefault = this.propertyForm.value['systemDefault']; - return systemDefault; + return systemDefault; } /** * Method updates the state of the value field based on the system default checkbox. */ updateValueState(): void { - if (!this.isDomainProperty || !this.isSystemDefault) { + if (!this.isDomainProperty || !this.isSystemDefault) { this.propertyForm.controls['value'].enable(); this.propertyForm.controls['value'].setValue(this.current.value); } else { @@ -249,7 +261,7 @@ export class PropertyDetailsDialogComponent implements OnInit { return this.propertyType == PropertyTypeEnum.DOMAIN; } - capitalize<T extends string>(str: T):string{ + capitalize<T extends string>(str: T): string { return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()) as Capitalize<T>; } diff --git a/smp-angular/src/app/common/enums/property-type.enum.ts b/smp-angular/src/app/common/enums/property-type.enum.ts index c72598815..95bfa7a7c 100644 --- a/smp-angular/src/app/common/enums/property-type.enum.ts +++ b/smp-angular/src/app/common/enums/property-type.enum.ts @@ -4,5 +4,5 @@ export enum PropertyTypeEnum { * Resource, group of domain is marked as PUBLIC. */ DOMAIN= 'DOMAIN', - SYSTEM= "SYSTEM", + SYSTEM= 'SYSTEM', } diff --git a/smp-angular/src/app/edit/edit-group/group-resource-panel/resource-dialog/resource-dialog.component.ts b/smp-angular/src/app/edit/edit-group/group-resource-panel/resource-dialog/resource-dialog.component.ts index 8a05ea83b..90f356da5 100644 --- a/smp-angular/src/app/edit/edit-group/group-resource-panel/resource-dialog/resource-dialog.component.ts +++ b/smp-angular/src/app/edit/edit-group/group-resource-panel/resource-dialog/resource-dialog.component.ts @@ -9,7 +9,6 @@ import {DomainRo} from "../../../../common/model/domain-ro.model"; import {ResourceDefinitionRo} from "../../../../system-settings/admin-extension/resource-definition-ro.model"; import {EditGroupService} from "../../edit-group.service"; import {GlobalLookups} from "../../../../common/global-lookups"; -import {EntityStatus} from "../../../../common/enums/entity-status.enum"; @Component({ diff --git a/smp-angular/src/app/system-settings/admin-domain/domain-properties-panel/domain-properties-panel.component.html b/smp-angular/src/app/system-settings/admin-domain/domain-properties-panel/domain-properties-panel.component.html index 32870d026..dd0103d78 100644 --- a/smp-angular/src/app/system-settings/admin-domain/domain-properties-panel/domain-properties-panel.component.html +++ b/smp-angular/src/app/system-settings/admin-domain/domain-properties-panel/domain-properties-panel.component.html @@ -35,13 +35,13 @@ <mat-toolbar-row class="smp-toolbar-row"> <button id="cancelButton" mat-raised-button (click)="onResetButtonClicked()" color="primary" - [disabled]="!resetButtonEnabled"> + [disabled]="!cancelButtonEnabled"> <mat-icon>refresh</mat-icon> <span>Reset</span> </button> <button id="saveButton" mat-raised-button (click)="onSaveButtonClicked()" color="primary" - [disabled]="!submitButtonEnabled"> + [disabled]="!saveButtonEnabled"> <mat-icon>save</mat-icon> <span>Save</span> </button> diff --git a/smp-angular/src/app/system-settings/admin-domain/domain-properties-panel/domain-properties-panel.component.ts b/smp-angular/src/app/system-settings/admin-domain/domain-properties-panel/domain-properties-panel.component.ts index 58c3312ab..d9593e3dd 100644 --- a/smp-angular/src/app/system-settings/admin-domain/domain-properties-panel/domain-properties-panel.component.ts +++ b/smp-angular/src/app/system-settings/admin-domain/domain-properties-panel/domain-properties-panel.component.ts @@ -89,11 +89,11 @@ export class DomainPropertiesPanelComponent implements OnInit, OnDestroy, Before return {...this._domain}; } - get submitButtonEnabled(): boolean { + get saveButtonEnabled(): boolean { return this.dataChanged; } - get resetButtonEnabled(): boolean { + get cancelButtonEnabled(): boolean { return this.dataChanged; } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/config/enums/SMPPropertyEnum.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/config/enums/SMPPropertyEnum.java index 1afee83d4..931c13213 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/config/enums/SMPPropertyEnum.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/config/enums/SMPPropertyEnum.java @@ -85,7 +85,7 @@ public enum SMPPropertyEnum { // SML integration! SML_ENABLED("bdmsl.integration.enabled", "false", "BDMSL (SML) integration ON/OFF switch", OPTIONAL, NOT_ENCRYPTED, NO_RESTART_NEEDED, BOOLEAN), - SML_MANAMGE_MAX_COUNT("bdmsl.participants.manage.max-count", "10000", "Maximum number of participants which can be registered/unregistered in one call of register/unregister domain", + SML_MANAGE_MAX_COUNT("bdmsl.participants.manage.max-count", "10000", "Maximum number of participants which can be registered/unregistered in one call of register/unregister domain", OPTIONAL, NOT_ENCRYPTED, NO_RESTART_NEEDED, INTEGER), SML_URL("bdmsl.integration.url", "http://localhost:8080/edelivery-sml", "BDMSL (SML) endpoint", OPTIONAL, NOT_ENCRYPTED, NO_RESTART_NEEDED, URL), diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/DBDomainConfToDomainPropROConverter.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/DBDomainConfToDomainPropROConverter.java index 9ff61aefc..8a7ea6735 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/DBDomainConfToDomainPropROConverter.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/DBDomainConfToDomainPropROConverter.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Component; /** * Converts a {@link DBDomainConfiguration} to a {@link DomainPropertyRO}. * - * @author Joze Rihtars + * @author Joze Rihtarsic * @since 5.1 */ @Component diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ConfigurationService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ConfigurationService.java index 3faadf974..4e2f10c83 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ConfigurationService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ConfigurationService.java @@ -398,7 +398,7 @@ public class ConfigurationService { } public int getManageMaxSMLRecordCount() { - Integer intVal = configurationDAO.getCachedPropertyValue(SML_MANAMGE_MAX_COUNT); + Integer intVal = configurationDAO.getCachedPropertyValue(SML_MANAGE_MAX_COUNT); return intVal == null ? 10000 : intVal; } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/DomainSMLIntegrationService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/DomainSMLIntegrationService.java index 3b3bd6e6e..1c47450b2 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/DomainSMLIntegrationService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/DomainSMLIntegrationService.java @@ -34,7 +34,7 @@ import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; -import static eu.europa.ec.edelivery.smp.config.enums.SMPPropertyEnum.SML_MANAMGE_MAX_COUNT; +import static eu.europa.ec.edelivery.smp.config.enums.SMPPropertyEnum.SML_MANAGE_MAX_COUNT; /** @@ -92,7 +92,7 @@ public class DomainSMLIntegrationService { if (resourceCnt > maxSMLRecordCount) { LOG.warn("Too many resources to register for the domain [{}]. Count: [{}], max. allowed [{}]!" + "For details check the configuration option [{}]!", - dbDomain, resourceCnt, maxSMLRecordCount, SML_MANAMGE_MAX_COUNT.getProperty()); + dbDomain, resourceCnt, maxSMLRecordCount, SML_MANAGE_MAX_COUNT.getProperty()); return; } @@ -129,7 +129,7 @@ public class DomainSMLIntegrationService { if (resourceCnt > maxSMLRecordCount) { LOG.warn("Too many resources to unregister for the domain [{}]. Count: [{}], max. allowed [{}]!" + "For details check the configuration option [{}]!", - dbDomain, resourceCnt, maxSMLRecordCount, SML_MANAMGE_MAX_COUNT.getProperty()); + dbDomain, resourceCnt, maxSMLRecordCount, SML_MANAGE_MAX_COUNT.getProperty()); return; } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainAdminService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainAdminService.java index fb430a8d5..5b515363c 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainAdminService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainAdminService.java @@ -45,6 +45,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -59,7 +60,6 @@ public class UIDomainAdminService extends UIServiceBase<DBDomain, DomainRO> { private static final SMPLogger LOG = SMPLoggerFactory.getLogger(UIDomainAdminService.class); - private final DomainDao domainDao; private final DomainMemberDao domainMemberDao; private final ResourceDao resourceDao; @@ -262,7 +262,7 @@ public class UIDomainAdminService extends UIServiceBase<DBDomain, DomainRO> { } // get current domain configuration Map<String, DBDomainConfiguration> currentDomainConfiguration = domainDao.getDomainConfiguration(domain) - .stream().collect(Collectors.toMap(DBDomainConfiguration::getProperty, dp -> dp)); + .stream().collect(Collectors.toMap(DBDomainConfiguration::getProperty, Function.identity())); Map<String, DomainPropertyRO> newDomainPropertyValues = domainProperties.stream().collect(Collectors.toMap(DomainPropertyRO::getProperty, dp -> dp)); @@ -273,7 +273,8 @@ public class UIDomainAdminService extends UIServiceBase<DBDomain, DomainRO> { DBDomainConfiguration domainConfiguration = currentDomainConfiguration.get(domainProp.getProperty()); DomainPropertyRO domainPropertyRO = newDomainPropertyValues.get(domainProp.getProperty()); // if property already exists in the database, update value - DBDomainConfiguration updatedDomainProp = domainDao.updateDomainProperty(domain, domainProp, domainConfiguration, domainPropertyRO); + DBDomainConfiguration updatedDomainProp = domainDao.updateDomainProperty(domain, domainProp, + domainConfiguration, domainPropertyRO); listOfDomainConfiguration.add(updatedDomainProp); // remove updated property from the map currentDomainConfiguration.remove(domainProp.getProperty()); diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainEditService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainEditService.java index a611be43e..c33165fb5 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainEditService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIDomainEditService.java @@ -275,13 +275,23 @@ public class UIDomainEditService extends UIServiceBase<DBDomain, DomainPublicRO> propertyValidationRO.setPropertyValid(false); return propertyValidationRO; } - SMPDomainPropertyEnum propertyEnum = optPropertyEnum.get(); + SMPDomainPropertyEnum propertyEnum = optPropertyEnum.get(); + return validateDomainPropertyValue(propertyEnum, propertyValidationRO); + } + /** + * Method validates domain property value for given property enum. + * @param propertyEnum - property enum + * @param propertyValidationRO - property validation object with value. + * @return property validation object with validation result and error message if validation failed. + */ + private PropertyValidationRO validateDomainPropertyValue(SMPDomainPropertyEnum propertyEnum, + PropertyValidationRO propertyValidationRO) { // try to parse value try { File confDir = Paths.get(SMPEnvironmentProperties.getInstance().getEnvPropertyValue(SMPEnvPropertyEnum.SECURITY_FOLDER)).toFile(); - PropertyUtils.parseProperty(propertyEnum.getPropertyEnum(), propertyRO.getValue(), confDir); + PropertyUtils.parseProperty(propertyEnum.getPropertyEnum(), propertyValidationRO.getValue(), confDir); } catch (SMPRuntimeException ex) { propertyValidationRO.setErrorMessage(ex.getMessage()); propertyValidationRO.setPropertyValid(false); diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/edit/DomainEditController.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/edit/DomainEditController.java index 56412a026..48af60e66 100644 --- a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/edit/DomainEditController.java +++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/edit/DomainEditController.java @@ -168,19 +168,19 @@ public class DomainEditController { } /** - * Method returns ALL domain properties for domain for authenticated/authorized user. If the property is not set - * default value is returned with isSystemDefault set to true. + * Method validates authorization for the users and updates all given properties. + * As the result it returns ALL (updated) domain properties. * * @param userEncId encrypted user identifier * @param domainEncId the encrypted domain identifier - * @return list of domain properties + * @return list of domain properties to be updated. */ @PostMapping(path = SUB_CONTEXT_PATH_EDIT_DOMAIN_PROPERTIES, produces = MimeTypeUtils.APPLICATION_JSON_VALUE) @PreAuthorize("@smpAuthorizationService.isCurrentlyLoggedIn(#userEncId) and @smpAuthorizationService.isDomainAdministrator(#domainEncId)") public List<DomainPropertyRO> updateEditDomainPropertyList(@PathVariable(PATH_PARAM_ENC_USER_ID) String userEncId, @PathVariable(PATH_PARAM_ENC_DOMAIN_ID) String domainEncId, @RequestBody List<DomainPropertyRO> domainProperties) { - logAdminAccess("getDomainPropertyList:" + domainEncId); + logAdminAccess("updateEditDomainPropertyList:" + domainEncId); Long domainId = SessionSecurityUtils.decryptEntityId(domainEncId); LOG.debug("Update domain properties for domain with id [{}]", domainId); return uiDomainEditService.updateDomainEditProperties(domainId, domainProperties); diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/internal/DomainAdminController.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/internal/DomainAdminController.java index 4762bb69f..678ec3218 100644 --- a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/internal/DomainAdminController.java +++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/internal/DomainAdminController.java @@ -200,8 +200,8 @@ public class DomainAdminController { } /** - * Method returns ALL domain properties for domain for authenticated/authorized user. If the property is not set - * default value is returned with isSystemDefault set to true. + * Method validates the authorization for the user and update the given domain properties. As a result + * it returns ALL domain properties after the update. * * @param userEncId encrypted user identifier * @param domainEncId the encrypted domain identifier @@ -212,7 +212,7 @@ public class DomainAdminController { public List<DomainPropertyRO> updateDomainPropertyList(@PathVariable(PATH_PARAM_ENC_USER_ID) String userEncId, @PathVariable(PATH_PARAM_ENC_DOMAIN_ID) String domainEncId, @RequestBody List<DomainPropertyRO> domainProperties) { - logAdminAccess("getDomainPropertyList:" + domainEncId); + logAdminAccess("updateDomainPropertyList:" + domainEncId); Long domainId = SessionSecurityUtils.decryptEntityId(domainEncId); LOG.debug("Update domain properties for domain with id [{}]", domainId); return uiDomainService.updateDomainProperties(domainId, domainProperties); -- GitLab