Code development platform for open source projects from the European Union institutions

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

Pull request #237: Add error message to the metadata service wizard dialog

Merge in EDELIVERY/smp from EDELIVERY-9785-in-the-service-metadata-wizard-when-uploading-certificate-if-the-user-chooses-invalid to development

* commit '10806d0a8059442cd872b785a895569e014421c9':
  Add error message to the metadata service wizard dialog
parents 74f644e3 62a51259
No related branches found
No related tags found
No related merge requests found
...@@ -74,6 +74,12 @@ ...@@ -74,6 +74,12 @@
<button mat-flat-button color="primary" <button mat-flat-button color="primary"
(click)="fileInput.click()" >Upload certificate</button> (click)="fileInput.click()" >Upload certificate</button>
</label> </label>
<div *ngIf="certificateValidationMessage"
[ngClass]="{ 'alert-message': certificateValidationMessage, 'alert-message-success': !certificateValidationMessage, 'alert-message-error':!!certificateValidationMessage }"
id="alertmessage_id">
<span class="alert-message-close-button" (click)="clearAlert()">&times;</span>
{{certificateValidationMessage}}
</div>
<textarea matInput style="width:100%;border: #03A9F4 1px solid" cols="2" rows="10" <textarea matInput style="width:100%;border: #03A9F4 1px solid" cols="2" rows="10"
resizeable="false" resizeable="false"
id="metadatacertificate_id" id="metadatacertificate_id"
......
...@@ -76,6 +76,7 @@ export class ServiceMetadataWizardDialogComponent { ...@@ -76,6 +76,7 @@ export class ServiceMetadataWizardDialogComponent {
uploadCertificate(event) { uploadCertificate(event) {
const file = event.target.files[0]; const file = event.target.files[0];
this.certificateValidationMessage = null;
this.certificateService.validateCertificate(file).subscribe((res: CertificateRo) => { this.certificateService.validateCertificate(file).subscribe((res: CertificateRo) => {
if (res && res.certificateId) { if (res && res.certificateId) {
...@@ -83,15 +84,19 @@ export class ServiceMetadataWizardDialogComponent { ...@@ -83,15 +84,19 @@ export class ServiceMetadataWizardDialogComponent {
'endpointCertificate': res.encodedValue 'endpointCertificate': res.encodedValue
}); });
} else { } else {
this.alertService.exception("Error occurred while reading certificate.", "Check if uploaded file has valid certificate type.", false); this.certificateValidationMessage = 'Error occurred while reading certificate. Check if uploaded file has valid certificate type';
} }
}, },
err => { err => {
this.alertService.exception('Error uploading certificate file ' +file.name, err.error?.errorDescription); this.certificateValidationMessage = 'Error uploading certificate file [' + file.name + '] ' + err.error?.errorDescription;
} }
); );
} }
clearAlert() {
this.certificateValidationMessage = null;
}
onFileChanged(event) { onFileChanged(event) {
this.selectedFile = event.target.files[0] this.selectedFile = event.target.files[0]
...@@ -125,24 +130,25 @@ export class ServiceMetadataWizardDialogComponent { ...@@ -125,24 +130,25 @@ export class ServiceMetadataWizardDialogComponent {
getParticipantElementXML(): string { getParticipantElementXML(): string {
let schema = this.dialogForm.controls['participantScheme'].value; let schema = this.dialogForm.controls['participantScheme'].value;
let value= this.dialogForm.controls['participantIdentifier'].value; let value = this.dialogForm.controls['participantIdentifier'].value;
if (!!schema && this.lookups.cachedApplicationConfig.concatEBCorePartyId && if (!!schema && this.lookups.cachedApplicationConfig.concatEBCorePartyId &&
schema.startsWith(ServiceMetadataWizardDialogComponent.EBCORE_IDENTIFIER_PREFIX) ) { schema.startsWith(ServiceMetadataWizardDialogComponent.EBCORE_IDENTIFIER_PREFIX)) {
value = schema + ":" + value; value = schema + ":" + value;
schema =null; schema = null;
} }
return '<ParticipantIdentifier ' + return '<ParticipantIdentifier ' +
(!schema?'': 'scheme="' + this.xmlSpecialChars(schema) + '"')+ '>' (!schema ? '' : 'scheme="' + this.xmlSpecialChars(schema) + '"') + '>'
+ this.xmlSpecialChars(value)+ '</ParticipantIdentifier>'; + this.xmlSpecialChars(value) + '</ParticipantIdentifier>';
} }
getDocumentElementXML(): string { getDocumentElementXML(): string {
return ' <DocumentIdentifier ' + return ' <DocumentIdentifier ' +
(!this.dialogForm.controls['documentIdentifierScheme'].value?'': 'scheme="' (!this.dialogForm.controls['documentIdentifierScheme'].value ? '' : 'scheme="'
+ this.xmlSpecialChars(this.dialogForm.controls['documentIdentifierScheme'].value) + '"') + + this.xmlSpecialChars(this.dialogForm.controls['documentIdentifierScheme'].value) + '"') +
'>' + this.xmlSpecialChars(this.dialogForm.controls['documentIdentifier'].value) + '</DocumentIdentifier>'; '>' + this.xmlSpecialChars(this.dialogForm.controls['documentIdentifier'].value) + '</DocumentIdentifier>';
} }
getServiceMetadataXML() { getServiceMetadataXML() {
let exampleXML = '<ServiceMetadata xmlns="http://docs.oasis-open.org/bdxr/ns/SMP/2016/05">' + let exampleXML = '<ServiceMetadata xmlns="http://docs.oasis-open.org/bdxr/ns/SMP/2016/05">' +
...@@ -152,14 +158,14 @@ export class ServiceMetadataWizardDialogComponent { ...@@ -152,14 +158,14 @@ export class ServiceMetadataWizardDialogComponent {
'\n <ProcessList>' + '\n <ProcessList>' +
'\n <Process>' + '\n <Process>' +
'\n <ProcessIdentifier ' + '\n <ProcessIdentifier ' +
(!this.dialogForm.controls['processScheme'].value?'': 'scheme="' + this.xmlSpecialChars(this.dialogForm.controls['processScheme'].value) + '"')+ (!this.dialogForm.controls['processScheme'].value ? '' : 'scheme="' + this.xmlSpecialChars(this.dialogForm.controls['processScheme'].value) + '"') +
'>'+this.xmlSpecialChars(this.dialogForm.controls['processIdentifier'].value)+'</ProcessIdentifier>' + '>' + this.xmlSpecialChars(this.dialogForm.controls['processIdentifier'].value) + '</ProcessIdentifier>' +
'\n <ServiceEndpointList>' + '\n <ServiceEndpointList>' +
'\n <Endpoint transportProfile="'+this.xmlSpecialChars(this.dialogForm.controls['transportProfile'].value)+'">' + '\n <Endpoint transportProfile="' + this.xmlSpecialChars(this.dialogForm.controls['transportProfile'].value) + '">' +
'\n <EndpointURI>'+this.xmlSpecialChars(this.dialogForm.controls['endpointUrl'].value)+'</EndpointURI>' + '\n <EndpointURI>' + this.xmlSpecialChars(this.dialogForm.controls['endpointUrl'].value) + '</EndpointURI>' +
'\n <Certificate>'+this.xmlSpecialChars(this.dialogForm.controls['endpointCertificate'].value)+'</Certificate>' + '\n <Certificate>' + this.xmlSpecialChars(this.dialogForm.controls['endpointCertificate'].value) + '</Certificate>' +
'\n <ServiceDescription>'+this.xmlSpecialChars(this.dialogForm.controls['serviceDescription'].value)+'</ServiceDescription>' + '\n <ServiceDescription>' + this.xmlSpecialChars(this.dialogForm.controls['serviceDescription'].value) + '</ServiceDescription>' +
'\n <TechnicalContactUrl>'+this.xmlSpecialChars(this.dialogForm.controls['technicalContactUrl'].value)+'</TechnicalContactUrl>' + '\n <TechnicalContactUrl>' + this.xmlSpecialChars(this.dialogForm.controls['technicalContactUrl'].value) + '</TechnicalContactUrl>' +
'\n </Endpoint>' + '\n </Endpoint>' +
'\n </ServiceEndpointList>' + '\n </ServiceEndpointList>' +
'\n </Process>' + '\n </Process>' +
......
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