Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 65b2accd authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

[EDELIVERY-13860] Fix DNS tool identifier validation to use default identifier settings.

parent 3a7d1e55
No related branches found
No related tags found
No related merge requests found
Pipeline #201875 failed
......@@ -17,12 +17,28 @@
<input matInput name="ResourceIdentifier"
formControlName="resourceIdentifier"
id="resource-identifier-id">
<div
*ngIf="(dnsToolsForm.controls['resourceIdentifier'].touched ) && dnsToolsForm.controls['resourceIdentifier'].hasError('required')"
style="color:red; font-size: 70%">
{{ "dns.tools.resource.id.mandatory" | translate }}
</div>
</mat-form-field>
<mat-form-field class="smp-data-panel-field">
<mat-label>{{ "dns.tools.label.resource.scheme" | translate }}</mat-label>
<input matInput name="ResourceScheme"
formControlName="resourceScheme"
id="resource-scheme-id">
<div
*ngIf="(dnsToolsForm.controls['resourceScheme'].touched ) && dnsToolsForm.controls['resourceScheme'].hasError('required')"
style="color:red; font-size: 70%">
{{ "dns.tools.label.resource.scheme.mandatory" | translate }}
</div>
<div
*ngIf="(dnsToolsForm.controls['resourceScheme'].touched ) &&
dnsToolsForm.controls['resourceScheme'].hasError('pattern')"
style="color:red; font-size: 70%">
{{participantSchemeMessage}}
</div>
</mat-form-field>
<mat-form-field class="smp-data-panel-field">
<mat-label>{{ "dns.tools.label.resource.top.domain" | translate }}</mat-label>
......@@ -39,6 +55,13 @@
<mat-icon>input</mat-icon>
<span>{{ "dns.tools.button.generate.lookup.query" | translate }}</span>
</button>
<tool-button-spacer></tool-button-spacer>
<button mat-raised-button color="primary" (click)="clearData()"
[disabled]="!dnsToolsForm.dirty" id="clearallbutton_id">
<mat-icon>cancel</mat-icon>
<span>{{ "form.button.clear" | translate }}</span>
</button>
</div>
</ng-template>
</form>
......
import {Component} from "@angular/core";
import {DnsToolsService} from "./dns-tools.service";
import {DnsQueryRo} from "../../common/model/dns-query-ro.model";
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
import {FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms";
import {GlobalLookups} from "../../common/global-lookups";
import {
AlertMessageService
} from "../../common/alert-message/alert-message.service";
@Component({
templateUrl: './dns-tools.component.html',
......@@ -14,18 +17,33 @@ export class DnsToolsComponent {
dnsToolsForm: FormGroup;
private _result: DnsQueryRo[];
participantSchemePattern: string = '^[a-z0-9]+-[a-z0-9]+-[a-z0-9]+$';
participantSchemeMessage: string;
submitInProgress: boolean = false;
constructor(private dnsToolsService: DnsToolsService,
private lookups: GlobalLookups,
private alertService: AlertMessageService,
private formBuilder: FormBuilder) {
this.dnsToolsForm = formBuilder.group({
// common values
'resourceIdentifier': ['', Validators.required],
'resourceScheme': [''],
'resourceIdentifier': new FormControl({value: null}, [Validators.required]),
'resourceScheme': new FormControl({value: null}, [Validators.pattern(this.participantSchemePattern)]),
'dnsTopDomain': [''],
});
}
this.clearData();
// set the default system validation values
if (this.lookups.cachedApplicationConfig) {
this.participantSchemePattern = this.lookups.cachedApplicationConfig.participantSchemaRegExp != null ?
this.lookups.cachedApplicationConfig.participantSchemaRegExp : ".*"
this.participantSchemeMessage = this.lookups.cachedApplicationConfig.participantSchemaRegExpMessage;
}
if (!!lookups.cachedApplicationConfig.partyIDSchemeMandatory) {
this.dnsToolsForm.controls['resourceScheme'].addValidators(Validators.required);
}
}
get result(): DnsQueryRo[] {
......@@ -38,8 +56,25 @@ export class DnsToolsComponent {
this.dnsToolsForm.get('dnsTopDomain').value,
this.dnsToolsForm.get('resourceIdentifier').value,
this.dnsToolsForm.get('resourceScheme').value
).subscribe((res: DnsQueryRo[]) => {
this._result = res;
).subscribe({
next: (res: DnsQueryRo[]): void => {
this._result = res;
}, error: (err: any): void => {
this.alertService.error(err);
}
})
}
get submitButtonEnabled(): boolean {
return this.dnsToolsForm.valid && this.dnsToolsForm.dirty && !this.submitInProgress;
}
clearData(): void {
this.dnsToolsForm.get('dnsTopDomain').setValue("");
this.dnsToolsForm.get('resourceIdentifier').setValue("");
this.dnsToolsForm.get('resourceScheme').setValue("");
this._result = [];
this.dnsToolsForm.markAsPristine();
this.dnsToolsForm.markAsUntouched();
}
}
......@@ -757,6 +757,8 @@
"dns.tools.label.resource.top.domain": "Top domain",
"dns.tools.description": "Enter the DNS data to create DNS query",
"dns.tools.title": "DNS lookup",
"dns.tools.resource.id.mandatory": "Resource identifier is required!",
"dns.tools.resource.scheme.mandatory": "Resource scheme is required!",
"access.token.panel.button.delete": "Delete",
"access.token.panel.button.save": "Save",
......@@ -848,5 +850,7 @@
"navigation.label.user.settings.membership": "Membership",
"navigation.tooltip.search.resources": "Search registered resources",
"navigation.tooltip.search.tools": "Search tools",
"navigation.tooltip.search.dns.tools": "DNS lookup tools"
"navigation.tooltip.search.dns.tools": "DNS lookup tools",
"form.button.clear": "Clear"
}
......@@ -22,6 +22,7 @@ import eu.europa.ec.edelivery.smp.config.PropertyUpdateListener;
import eu.europa.ec.edelivery.smp.config.enums.SMPPropertyEnum;
import eu.europa.ec.edelivery.smp.logging.SMPLogger;
import eu.europa.ec.edelivery.smp.logging.SMPLoggerFactory;
import eu.europa.ec.edelivery.smp.services.IdentifierFormatterService;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.stereotype.Component;
......@@ -51,7 +52,9 @@ import static eu.europa.ec.edelivery.smp.config.enums.SMPPropertyEnum.*;
public class SMPIdentifierServicePropertyUpdateListener implements PropertyUpdateListener {
private static final SMPLogger LOG = SMPLoggerFactory.getLogger(SMPIdentifierServicePropertyUpdateListener.class);
private static final List<String> namedCachesToClear = Arrays.asList("participantIdentifiers", "documentIdentifiers");
private static final List<String> namedCachesToClear = Arrays.asList(
IdentifierFormatterService.CACHE_NAME_DOMAIN_RESOURCE_IDENTIFIER_FORMATTER,
IdentifierFormatterService.CACHE_NAME_DOMAIN_SUBRESOURCE_IDENTIFIER_FORMATTER);
private final CacheManager cacheManager;
......@@ -66,7 +69,7 @@ public class SMPIdentifierServicePropertyUpdateListener implements PropertyUpdat
// reset formatter cache on shared property update
this.cacheManager.getCacheNames().stream()
.filter(namedCachesToClear::contains)
.map(cacheName -> this.cacheManager.getCache(cacheName))
.map(this.cacheManager::getCache)
.filter(Objects::nonNull)
.forEach(Cache::clear);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment