diff --git a/smp-angular/src/app/domain/domain-details-dialog/domain-details-dialog.component.ts b/smp-angular/src/app/domain/domain-details-dialog/domain-details-dialog.component.ts index 6271650cabbdacedb6fd45c5615747fbad840f59..c5e379ece8d38410c9958c64076115b1abd95e41 100644 --- a/smp-angular/src/app/domain/domain-details-dialog/domain-details-dialog.component.ts +++ b/smp-angular/src/app/domain/domain-details-dialog/domain-details-dialog.component.ts @@ -140,7 +140,7 @@ export class DomainDetailsDialogComponent { const reader = new FileReader(); reader.onload = (e) => { - this.certificateService.uploadCertificate$(reader.result).subscribe((res: CertificateRo) => { + this.certificateService.uploadCertificate$(file).subscribe((res: CertificateRo) => { if (res && res.certificateId){ this.domainForm.patchValue({ 'smlClientCertHeader': res.blueCoatHeader diff --git a/smp-angular/src/app/service-group-edit/service-group-edit.component.ts b/smp-angular/src/app/service-group-edit/service-group-edit.component.ts index 9b3e3e0c1c8048d4c8178006a76bd6788439cb47..30e2b1c66175c6cbf40c60637fe92db0b77d4540 100644 --- a/smp-angular/src/app/service-group-edit/service-group-edit.component.ts +++ b/smp-angular/src/app/service-group-edit/service-group-edit.component.ts @@ -181,11 +181,10 @@ export class ServiceGroupEditComponent implements OnInit { } createServiceGroupURL(row: any){ - - return encodeURIComponent(row.participantScheme+'::'+row.participantIdentifier); + return encodeURIComponent((!row.participantScheme? '' : row.participantScheme)+'::'+row.participantIdentifier); } createServiceMetadataURL(row: any, rowSMD: any){ - return encodeURIComponent(row.participantScheme+'::'+row.participantIdentifier)+'/services/'+ encodeURIComponent(rowSMD.documentIdentifierScheme+'::'+rowSMD.documentIdentifier); + return encodeURIComponent((!row.participantScheme? '': row.participantScheme)+'::'+row.participantIdentifier)+'/services/'+ encodeURIComponent((!rowSMD.documentIdentifierScheme?'':rowSMD.documentIdentifierScheme)+'::'+rowSMD.documentIdentifier); } } diff --git a/smp-angular/src/app/service-group-edit/service-group-metadata-dialog/service-group-metadata-dialog.component.html b/smp-angular/src/app/service-group-edit/service-group-metadata-dialog/service-group-metadata-dialog.component.html index d1e73a67e924ee40aba211e874acf8f082fedcf2..d882fd03e09c714f16fe5da354e779db4909e347 100644 --- a/smp-angular/src/app/service-group-edit/service-group-metadata-dialog/service-group-metadata-dialog.component.html +++ b/smp-angular/src/app/service-group-edit/service-group-metadata-dialog/service-group-metadata-dialog.component.html @@ -57,13 +57,13 @@ <mat-icon>settings_ethernet</mat-icon> <span>Generate XML</span> </button> - <!-- button mat-raised-button color="primary" + <button mat-raised-button color="primary" matTooltip="Opens wizard to configure ServiceMetadata xml." matTooltipPosition="below" (click)="onStartWizardDialog()"> <mat-icon>add_box</mat-icon> <span>Metadata wizard</span> - </button --> + </button> <button mat-raised-button color="primary" atTooltip="Validate serviceMetadata XML." matTooltipPosition="below" diff --git a/smp-angular/src/app/service-group-edit/service-group-metadata-dialog/service-group-metadata-dialog.component.ts b/smp-angular/src/app/service-group-edit/service-group-metadata-dialog/service-group-metadata-dialog.component.ts index 50fcfd9337018bf87f07dc094b912cb1761c46b7..fa508f39c3ed63ade5efb0b6df1e98c3022f9af9 100644 --- a/smp-angular/src/app/service-group-edit/service-group-metadata-dialog/service-group-metadata-dialog.component.ts +++ b/smp-angular/src/app/service-group-edit/service-group-metadata-dialog/service-group-metadata-dialog.component.ts @@ -1,5 +1,5 @@ import {Component, Inject, OnInit, ViewChild} from '@angular/core'; -import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from '@angular/material'; +import {MAT_DIALOG_DATA, MatDialog, MatDialogConfig, MatDialogRef} from '@angular/material'; import {FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms"; import {AlertService} from "../../alert/alert.service"; import {SearchTableEntityStatus} from "../../common/search-table/search-table-entity-status.model"; @@ -12,6 +12,7 @@ import {Observable} from "rxjs/internal/Observable"; import {HttpClient} from "@angular/common/http"; import {ServiceGroupDomainEditRo} from "../service-group-domain-edit-ro.model"; import {ServiceMetadataValidationEditRo} from "./service-metadata-validation-edit-ro.model"; +import {ServiceMetadataWizardRo} from "../service-metadata-wizard-dialog/service-metadata-wizard-edit-ro.model"; @Component({ selector: 'app-messagelog-dialog', @@ -92,12 +93,6 @@ export class ServiceGroupMetadataDialogComponent implements OnInit { }); } - // detect changes for updated values in mat-selection-list (check change detection operations) - // else the following error is thrown :xpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: - // 'aria-selected: false'. Current value: 'aria-selected: true' - // - //this.changeDetector.detectChanges() - } checkValidity(g: FormGroup) { @@ -120,7 +115,8 @@ export class ServiceGroupMetadataDialogComponent implements OnInit { let request: ServiceMetadataValidationEditRo = { participantScheme: this.dialogForm.controls['participantScheme'].value, participantIdentifier: this.dialogForm.controls['participantIdentifier'].value, - documentIdentifierScheme: this.dialogForm.controls['documentIdentifierScheme'].value, + documentIdentifierScheme: !this.dialogForm.controls['documentIdentifierScheme'].value?null: + this.dialogForm.controls['documentIdentifierScheme'].value, documentIdentifier: this.dialogForm.controls['documentIdentifier'].value, xmlContent: this.dialogForm.controls['xmlContent'].value, statusAction: this.editMode?SearchTableEntityStatus.UPDATED:SearchTableEntityStatus.NEW, @@ -147,12 +143,41 @@ export class ServiceGroupMetadataDialogComponent implements OnInit { } onStartWizardDialog() { - const formRef: MatDialogRef<any> = this.dialog.open(ServiceMetadataWizardDialogComponent); + + let serviceMetadataWizard: ServiceMetadataWizardRo = { + isNewServiceMetadata: !this.editMode, + participantIdentifier: this.dialogForm.controls['participantIdentifier'].value, + participantScheme: this.dialogForm.controls['participantScheme'].value, + documentIdentifier: this.dialogForm.controls['documentIdentifier'].value, + documentIdentifierScheme: this.dialogForm.controls['documentIdentifierScheme'].value, + processIdentifier: '', + processScheme: '', + transportProfile: 'bdxr-transport-ebms3-as4-v1p0', // default value for oasis AS4 + + endpointUrl: '', + endpointCertificate: '', + + serviceDescription: '', + technicalContactUrl: '', + + } + + let wizardInit: MatDialogConfig = { + data: serviceMetadataWizard + } + + + + const formRef: MatDialogRef<any> = this.dialog.open(ServiceMetadataWizardDialogComponent,wizardInit); formRef.afterClosed().subscribe(result => { if (result) { - let existingXML = this.dialogForm.controls['extension'].value; - let val = (existingXML ? existingXML + '\n' : '') + formRef.componentInstance.getExtensionXML(); - this.dialogForm.controls['extension'].setValue(val); + + let smw: ServiceMetadataWizardRo = formRef.componentInstance.getCurrent(); + this.dialogForm.controls['xmlContent'].setValue(smw.contentXML); + if(!this.editMode){ + this.dialogForm.controls['documentIdentifierScheme'].setValue(smw.documentIdentifierScheme); + this.dialogForm.controls['documentIdentifier'].setValue(smw.documentIdentifier); + } } }); } @@ -168,7 +193,6 @@ export class ServiceGroupMetadataDialogComponent implements OnInit { '\n <ServiceEndpointList>' + '\n <Endpoint transportProfile="bdxr-transport-ebms3-as4-v1p0">' + '\n <EndpointURI>https://mypage.eu</EndpointURI>' + - '\n <RequireBusinessLevelSignature>true</RequireBusinessLevelSignature>' + '\n <Certificate>UGFzdGUgYmFzZTY0IGVuY29kZWQgY2VydGlmaWNhdGUgb2YgQVA=</Certificate>' + '\n <ServiceDescription>Service description for partners</ServiceDescription>' + '\n <TechnicalContactUrl>www.best-page.eu</TechnicalContactUrl>' + @@ -195,7 +219,8 @@ export class ServiceGroupMetadataDialogComponent implements OnInit { participantScheme: this.dialogForm.controls['participantScheme'].value, participantIdentifier: this.dialogForm.controls['participantIdentifier'].value, - documentIdentifierScheme: this.dialogForm.controls['documentIdentifierScheme'].value, + documentIdentifierScheme: !this.dialogForm.controls['documentIdentifierScheme'].value?null: + this.dialogForm.controls['documentIdentifierScheme'].value, documentIdentifier: this.dialogForm.controls['documentIdentifier'].value, xmlContent: this.dialogForm.controls['xmlContent'].value, statusAction: this.editMode?SearchTableEntityStatus.UPDATED:SearchTableEntityStatus.NEW, @@ -235,6 +260,4 @@ export class ServiceGroupMetadataDialogComponent implements OnInit { compareDomainCode(sgDomain: ServiceGroupDomainEditRo, domainCode: String): boolean { return sgDomain.domainCode === domainCode; } - - } diff --git a/smp-angular/src/app/service-group-edit/service-metadata-edit-ro.model.ts b/smp-angular/src/app/service-group-edit/service-metadata-edit-ro.model.ts index 50880525b0a09c6af8bfe8d7eceb9c311e95c0a8..8f6e3dfa5d3c572f937003a66bd870af2997d4a6 100644 --- a/smp-angular/src/app/service-group-edit/service-metadata-edit-ro.model.ts +++ b/smp-angular/src/app/service-group-edit/service-metadata-edit-ro.model.ts @@ -3,7 +3,7 @@ import {SearchTableEntity} from "../common/search-table/search-table-entity.mode export interface ServiceMetadataEditRo extends SearchTableEntity { documentIdentifier: string; - documentIdentifierScheme : string; + documentIdentifierScheme?: string; smlSubdomain: string; domainCode: string; domainId: null, diff --git a/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-dialog.component.css b/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-dialog.component.css index 66c5204a6d4d3b0cee28761c51cfce5310bdb950..56d17f14a9f570666d338e534bd7acd002064d66 100644 --- a/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-dialog.component.css +++ b/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-dialog.component.css @@ -6,3 +6,12 @@ -moz-box-sizing: border-box; /* FF1+ */ box-sizing: border-box; /* Chrome, IE8, Opera, Safari 5.1*/ } + +#certificate-file-upload { + display: none; +} + +.custom-file-upload { + display: inline-block; + cursor: pointer; +} diff --git a/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-dialog.component.html b/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-dialog.component.html index 73ca478dfb232258fae6fbeb3b2c6cfcbf54c9b6..3540d6360d192f94aa745468e17e577b2668e98a 100644 --- a/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-dialog.component.html +++ b/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-dialog.component.html @@ -5,99 +5,100 @@ <mat-card> <mat-card-content> <div class="panel"> - <!-- Participant --> - <mat-form-field style="width:35%"> - <input matInput placeholder="Participant identifier scheme" name="participantIdentifierScheme" - id="participantIdentifierScheme_id" maxlength="255"> - </mat-form-field> - <mat-form-field style="width:60%"> - <input matInput placeholder="Participant identifier" name="ParticipantIdentifier" id="ParticipantIdentifier_id" - maxlength="255" required> - <div - *ngIf="(!editMode && dialogForm.controls['documentIdentifier'].touched || editMode) && dialogForm.controls['documentIdentifier'].hasError('required')" - style="color:red; font-size: 70%"> - Document identifier must not be empty. - </div> - </mat-form-field> + <!-- Document --> <mat-form-field style="width:35%"> <input matInput placeholder="Document identifier scheme" name="documentIdentifierScheme" id="documentIdentifierScheme_id" + [formControl]="dialogForm.controls['documentIdentifierScheme']" maxlength="255"> </mat-form-field> <mat-form-field style="width:60%"> <input matInput placeholder="Document identifier" name="documentIdentifier" id="documentIdentifier_id" - maxlength="255" required> + maxlength="255" + [formControl]="dialogForm.controls['documentIdentifier']" + required> + <div + *ngIf="dialogForm.controls['documentIdentifier'].touched && dialogForm.controls['documentIdentifier'].hasError('required')" + style="color:red; font-size: 70%">Document identifier is required! + </div> </mat-form-field> <!-- Process --> <mat-form-field style="width:35%"> <input matInput placeholder="Process scheme" name="processSchema" id="processSchema_id" - maxlength="255" required> + maxlength="255" + [formControl]="dialogForm.controls['processScheme']" + > </mat-form-field> <mat-form-field style="width:60%"> <input matInput placeholder="Process identifier" name="processidentifier" id="processidentifier_id" - maxlength="255" required> - + maxlength="255" + [formControl]="dialogForm.controls['processIdentifier']" + required> + <div + *ngIf="dialogForm.controls['processIdentifier'].touched && dialogForm.controls['processIdentifier'].hasError('required')" + style="color:red; font-size: 70%">Process identifier is required! + </div> </mat-form-field> <!-- transport --> <mat-form-field style="width:35%"> <input matInput placeholder="Transport profile" name="transportProfile" id="transportProfiler_id" - maxlength="255" required> + maxlength="255" + [formControl]="dialogForm.controls['transportProfile']" + required> + <div + *ngIf="dialogForm.controls['transportProfile'].touched && dialogForm.controls['transportProfile'].hasError('required')" + style="color:red; font-size: 70%">Transport profile (as example: bdxr-transport-ebms3-as4-v1p0) is required! + </div> </mat-form-field> <mat-form-field style="width:60%"> <input matInput placeholder="Endpoint Url" name="endpointUrl" id="endpointUrl_id" - maxlength="255" required> + maxlength="255" + [formControl]="dialogForm.controls['endpointUrl']" + type="url" + required> + <div + *ngIf="dialogForm.controls['endpointUrl'].touched && dialogForm.controls['endpointUrl'].hasError('required')" + style="color:red; font-size: 70%">Access point URL is required! + </div> </mat-form-field> <div style="display: block;" style="border:1px; solid: #999999;margin:5px 0; padding:3px;"> - <input - type="file" (change)="onFileChanged($event)" - #fileInput> - <button (click)="onUpload()">Upload!</button> - <div class="textwrapper"> + <label class="custom-file-upload"> + <input #fileInput type="file" style="display: inline-block;cursor: pointer; display: none;" + id="certificate-file-upload" accept=".cer,.crt,.pem,.der" + (change)="uploadCertificate($event)"> + <button mat-flat-button color="primary" + (click)="fileInput.click()" >Upload certificate</button> + </label> <textarea matInput style="width:100%;border: #03A9F4 1px solid" cols="2" rows="10" resizeable="false" id="metadatacertificate_id" - placeholder="X509Certificate" name="certificate" - - ></textarea> - </div> - <div - *ngIf="certificateValidationMessage" - [style.color]="isCertificateValid?'green':'red'"> - {{certificateValidationMessage}} + placeholder="X509Certificate*" name="certificate" + [formControl]="dialogForm.controls['endpointCertificate']" + ></textarea> </div> - + <div + *ngIf="dialogForm.controls['endpointCertificate'].touched && dialogForm.controls['endpointCertificate'].hasError('required')" + style="color:red; font-size: 70%">Valid x509 Certificate is required! </div> + </div> - <!-- --> - - - <!-- mat-form-field style="width:47%"> - <input matInput placeholder="ServiceActivationDate" name="serviceActivationDate" id="serviceActivationDate_id" - [formControl]="dialogForm.controls['serviceActivationDate']" maxlength="255" required> - </mat-form-field> - <mat-form-field style="width:47%"> - <input matInput placeholder="ServiceExpirationDate" name="serviceExpirationDate" id="serviceExpirationDate" - [formControl]="dialogForm.controls['serviceExpirationDate']" maxlength="255" required> - </mat-form-field --> <!-- ServiceDescription --> <mat-form-field style="width:100%"> <input matInput placeholder="Service description" name="serviceDescription" id="serviceDescription_id" - [formControl]="dialogForm.controls['serviceDescription']" maxlength="255" required> + [formControl]="dialogForm.controls['serviceDescription']" maxlength="255" > </mat-form-field> <mat-form-field style="width:100%"> <input matInput placeholder="Technical Contact Url" name="technicalContactUrl" id="technicalContactUrl_id" - [formControl]="dialogForm.controls['technicalContactUrl_id']" maxlength="255" required> + [formControl]="dialogForm.controls['technicalContactUrl']" maxlength="255" type="url" > </mat-form-field> - - </div> </mat-card-content> </mat-card> </form> diff --git a/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-dialog.component.ts b/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-dialog.component.ts index ff3fe7f49a9c6c38aa0176a224dcff472cd9200d..a220e4332471c3063597e7294f76d55ed25de3e9 100644 --- a/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-dialog.component.ts +++ b/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-dialog.component.ts @@ -1,10 +1,13 @@ -import {Component} from '@angular/core'; -import {MatDialogRef} from '@angular/material'; +import {Component, Inject} from '@angular/core'; +import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material'; import {FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms"; import {HttpClient} from "@angular/common/http"; -import {SmpConstants} from "../../smp.constants"; -import {ServiceMetadataEditRo} from "../service-metadata-edit-ro.model"; import {CertificateService} from "../../user/certificate.service"; +import {CertificateRo} from "../../user/certificate-ro.model"; +import {AlertService} from "../../alert/alert.service"; +import {ServiceMetadataWizardRo} from "./service-metadata-wizard-edit-ro.model"; +import {ServiceMetadataEditRo} from "../service-metadata-edit-ro.model"; + @Component({ selector: 'service-metadata-wizard-dialog', @@ -16,33 +19,79 @@ export class ServiceMetadataWizardDialogComponent { static readonly NEW_MODE = 'New ServiceMetadata XML'; static readonly EDIT_MODE = 'Edit ServiceMetadata XML'; - editMode: boolean; - current: ServiceMetadataEditRo & { confirmation?: string }; + isNewServiceMetadata: boolean; + current: ServiceMetadataWizardRo + & { confirmation?: string }; dialogForm: FormGroup; certificateValidationMessage: string; isCertificateValid: string; selectedFile: File; - // dummyXML: string = "<!-- Custom element is mandatory by OASIS SMP schema.\n Replace following element with your XML structure. -->\n<ext:example xmlns:ext=\"http://my.namespace.eu\">my mandatory content</ext:example>" - constructor( + @Inject(MAT_DIALOG_DATA) public data: any, private http: HttpClient, private dialogRef: MatDialogRef<ServiceMetadataWizardDialogComponent>, + private alertService: AlertService, private dialogFormBuilder: FormBuilder, private certificateService: CertificateService, ) { + this.isNewServiceMetadata = this.data.isNewServiceMetadata; + + this.current = {...this.data} this.dialogForm = dialogFormBuilder.group({ - 'documentIdentifier': new FormControl({value: ''}, [Validators.required]), - 'documentIdentifierScheme': new FormControl({value: ''}, null), - 'processScheme': new FormControl({value: ''}, [Validators.required]), + 'participantIdentifier': new FormControl({value: '', disabled: true}, null), + 'participantScheme': new FormControl({value: '', disabled: true}, null), + + 'documentIdentifier': new FormControl({value: '', disabled: !this.isNewServiceMetadata}, [Validators.required]), + 'documentIdentifierScheme': new FormControl({value: '', disabled: !this.isNewServiceMetadata}, null), + 'processScheme': new FormControl({value: ''}, null), 'processIdentifier': new FormControl({value: ''}, [Validators.required]), + + 'transportProfile': new FormControl({value: ''}, [Validators.required]), 'endpointUrl': new FormControl({value: ''}, [Validators.required]), - 'endpointCertificate': new FormControl({value: ''}, null), + 'endpointCertificate': new FormControl({value: ''}, [Validators.required]), + 'serviceDescription': new FormControl({value: ''}, null), + 'technicalContactUrl': new FormControl({value: ''}, null), }); + + this.dialogForm.controls['participantIdentifier'].setValue(this.current.participantIdentifier); + this.dialogForm.controls['participantScheme'].setValue(this.current.participantScheme); + + this.dialogForm.controls['documentIdentifier'].setValue(this.current.documentIdentifier); + this.dialogForm.controls['documentIdentifierScheme'].setValue(this.current.documentIdentifierScheme); + this.dialogForm.controls['transportProfile'].setValue(this.current.transportProfile); + + this.dialogForm.controls['processScheme'].setValue(this.current.processScheme); + this.dialogForm.controls['processIdentifier'].setValue(this.current.processIdentifier); + this.dialogForm.controls['endpointUrl'].setValue(this.current.endpointUrl); + this.dialogForm.controls['endpointCertificate'].setValue(this.current.endpointCertificate); + this.dialogForm.controls['serviceDescription'].setValue(this.current.serviceDescription); + this.dialogForm.controls['technicalContactUrl'].setValue(this.current.technicalContactUrl); + } + + uploadCertificate(event) { + const file = event.target.files[0]; + this.certificateService.uploadCertificate$(file).subscribe((res: CertificateRo) => { + if (res && res.certificateId) { + + this.dialogForm.patchValue({ + 'endpointCertificate': res.encodedValue + }); + } else { + this.alertService.exception("Error occurred while reading certificate.", "Check if uploaded file has valid certificate type.", false); + } + }, + err => { + this.alertService.exception('Error uploading certificate file ' + file.name, err); + } + ); + } + + onFileChanged(event) { this.selectedFile = event.target.files[0] } @@ -55,19 +104,55 @@ export class ServiceMetadataWizardDialogComponent { }); } - getExtensionXML() { - /* - var xmlString = '<Extension xmlns="http://docs.oasis-open.org/bdxr/ns/SMP/2016/05">' - let arrayLength = this.elements.length; - for (var i = 0; i < arrayLength; i++) { - let str = this.dialogForm.get(this.elements[i].name).value; - if (str && 0 !== str.length) { - xmlString = xmlString + '\n <'+this.elements[i].name+'>' + this.xmlSpecialChars(str) + '</'+this.elements[i].name+'>'; - } - } - xmlString = xmlString+ '\n' +this.dummyXML+ '\n</Extension>' + public getCurrent(): ServiceMetadataWizardRo { + + + + this.current.participantIdentifier = this.dialogForm.controls['participantIdentifier'].value; + this.current.participantScheme = this.dialogForm.controls['participantScheme'].value; + this.current.documentIdentifier = this.dialogForm.controls['documentIdentifier'].value; + this.current.documentIdentifierScheme = this.dialogForm.controls['documentIdentifierScheme'].value; + this.current.transportProfile = this.dialogForm.controls['transportProfile'].value; + + this.current.endpointUrl = this.dialogForm.controls['endpointUrl'].value; + this.current.endpointCertificate = this.dialogForm.controls['endpointCertificate'].value; + this.current.serviceDescription = this.dialogForm.controls['serviceDescription'].value; + this.current.technicalContactUrl = this.dialogForm.controls['technicalContactUrl'].value; + this.current.contentXML = this.getServiceMetadataXML(); + + + return this.current; + } + + getServiceMetadataXML() { + + let exampleXML = '<ServiceMetadata xmlns="http://docs.oasis-open.org/bdxr/ns/SMP/2016/05">' + + '\n <ServiceInformation>' + + '\n <ParticipantIdentifier scheme="' + this.dialogForm.controls['participantScheme'].value + '">' + + this.dialogForm.controls['participantIdentifier'].value + '</ParticipantIdentifier>' + + '\n <DocumentIdentifier ' + + (!this.dialogForm.controls['documentIdentifierScheme'].value?'': 'scheme="' + + this.xmlSpecialChars(this.dialogForm.controls['documentIdentifierScheme'].value) + '"') + + '>' + this.xmlSpecialChars(this.dialogForm.controls['documentIdentifier'].value) + '</DocumentIdentifier>' + + '\n <ProcessList>' + + '\n <Process>' + + '\n <ProcessIdentifier ' + + (!this.dialogForm.controls['processScheme'].value?'': 'scheme="' + this.xmlSpecialChars(this.dialogForm.controls['processScheme'].value) + '"')+ + '>'+this.xmlSpecialChars(this.dialogForm.controls['processIdentifier'].value)+'</ProcessIdentifier>' + + '\n <ServiceEndpointList>' + + '\n <Endpoint transportProfile="'+this.xmlSpecialChars(this.dialogForm.controls['transportProfile'].value)+'">' + + '\n <EndpointURI>'+this.xmlSpecialChars(this.dialogForm.controls['endpointUrl'].value)+'</EndpointURI>' + + '\n <Certificate>'+this.xmlSpecialChars(this.dialogForm.controls['endpointCertificate'].value)+'</Certificate>' + + '\n <ServiceDescription>'+this.xmlSpecialChars(this.dialogForm.controls['serviceDescription'].value)+'</ServiceDescription>' + + '\n <TechnicalContactUrl>'+this.xmlSpecialChars(this.dialogForm.controls['technicalContactUrl'].value)+'</TechnicalContactUrl>' + + '\n </Endpoint>' + + '\n </ServiceEndpointList>' + + '\n </Process>' + + '\n </ProcessList>' + + '\n </ServiceInformation>' + + '\n</ServiceMetadata>'; - return xmlString;*/ + return exampleXML; } xmlSpecialChars(unsafe) { diff --git a/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-edit-ro.model.ts b/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-edit-ro.model.ts index 94cd2150e817eb519f2f035cfd97c24a341c20f4..a60e758479f70b4796b3626ec59796d0cd1c1d69 100644 --- a/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-edit-ro.model.ts +++ b/smp-angular/src/app/service-group-edit/service-metadata-wizard-dialog/service-metadata-wizard-edit-ro.model.ts @@ -1,6 +1,7 @@ export interface ServiceMetadataWizardRo { - participantIdentifierScheme: string; + isNewServiceMetadata: boolean; + participantScheme: string; participantIdentifier: string; documentIdentifierScheme: string; documentIdentifier: string; @@ -8,9 +9,9 @@ export interface ServiceMetadataWizardRo { processIdentifier: string; transportProfile: string; endpointUrl: string; - certificate: string; + endpointCertificate: string; serviceDescription: string; technicalContactUrl: string; - contentXML: string - errorMessage: string + contentXML?: string + errorMessage?: string } diff --git a/smp-angular/src/app/service-group-search/service-group-search.component.ts b/smp-angular/src/app/service-group-search/service-group-search.component.ts index 195da2f59ed456916a4b293292d14ad101afb569..70262d52f833e45b4f2c3135440764f8872ee3ca 100644 --- a/smp-angular/src/app/service-group-search/service-group-search.component.ts +++ b/smp-angular/src/app/service-group-search/service-group-search.component.ts @@ -69,12 +69,11 @@ export class ServiceGroupSearchComponent implements OnInit { } createServiceGroupURL(row: any){ - - return encodeURIComponent(row.participantScheme+'::'+row.participantIdentifier); + return encodeURIComponent((!row.participantScheme? '' : row.participantScheme)+'::'+row.participantIdentifier); } createServiceMetadataURL(row: any, rowSMD: any){ - return encodeURIComponent(row.participantScheme+'::'+row.participantIdentifier)+'/services/'+ encodeURIComponent(rowSMD.documentIdentifierScheme+'::'+rowSMD.documentIdentifier); + return encodeURIComponent((!row.participantScheme? '': row.participantScheme)+'::'+row.participantIdentifier)+'/services/'+ encodeURIComponent((!rowSMD.documentIdentifierScheme?'':rowSMD.documentIdentifierScheme)+'::'+rowSMD.documentIdentifier); } details(row: any) { diff --git a/smp-angular/src/app/user/certificate-ro.model.ts b/smp-angular/src/app/user/certificate-ro.model.ts index 5b996233e578f68656b0bd627eec5dd0fd748998..d00672fb14683810cbac122663f6f3085f69862c 100644 --- a/smp-angular/src/app/user/certificate-ro.model.ts +++ b/smp-angular/src/app/user/certificate-ro.model.ts @@ -7,4 +7,5 @@ export interface CertificateRo { serialNumber: string; fingerprints: string; blueCoatHeader?:string; + encodedValue?:string; } diff --git a/smp-angular/src/app/user/certificate.service.ts b/smp-angular/src/app/user/certificate.service.ts index 30508bf7b4d4ddb1af24ca42fef359410136f86e..41fa7ecca837839fb1d34971eab2813654b9fb6d 100644 --- a/smp-angular/src/app/user/certificate.service.ts +++ b/smp-angular/src/app/user/certificate.service.ts @@ -1,7 +1,7 @@ import {Injectable} from '@angular/core'; import {Observable} from 'rxjs'; import {CertificateRo} from './certificate-ro.model'; -import {HttpClient} from '@angular/common/http'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; import {SmpConstants} from "../smp.constants"; import {SecurityService} from "../security/security.service"; import {User} from "../security/user.model"; @@ -18,7 +18,12 @@ export class CertificateService { // The user identifier below belongs to the currently logged in user and it may or may not be the same as the // identifier of the user being modified (e.g. a normal user editing his own details vs. a system administrator // adding or editing another user) + + // upload file as binary file + const headers = new HttpHeaders() + .set("Content-Type", "application/octet-stream"); + const currentUser: User = this.securityService.getCurrentUser(); - return this.http.post<CertificateRo>(`${SmpConstants.REST_USER}/${currentUser.id}/certdata`, payload); + return this.http.post<CertificateRo>(`${SmpConstants.REST_USER}/${currentUser.id}/certdata`, payload, {headers}); } } diff --git a/smp-api/src/main/java/eu/europa/ec/smp/api/Identifiers.java b/smp-api/src/main/java/eu/europa/ec/smp/api/Identifiers.java index da32eb4eb481d4e79576e913a21d1cb8a2140fff..9ac289b3e4a349f3a81f28fb6d660b94d2286e4c 100644 --- a/smp-api/src/main/java/eu/europa/ec/smp/api/Identifiers.java +++ b/smp-api/src/main/java/eu/europa/ec/smp/api/Identifiers.java @@ -102,7 +102,7 @@ public class Identifiers { if (delimiterIndex<0){ throw new MalformedIdentifierException(doubleColonDelimitedId, null); } - idResult[0] = doubleColonDelimitedId.substring(0,delimiterIndex); + idResult[0] = delimiterIndex==0?null:doubleColonDelimitedId.substring(0,delimiterIndex); idResult[1] = doubleColonDelimitedId.substring(delimiterIndex+2); if (StringUtils.isBlank(idResult[1])){ diff --git a/smp-api/src/test/java/eu/europa/ec/smp/api/IdentifiersTest.java b/smp-api/src/test/java/eu/europa/ec/smp/api/IdentifiersTest.java index 66eaaaeab90f428286982c0210adebbfd03d6512..aaf94eac496607a4c0a9728bd98b50d52a6a89a5 100644 --- a/smp-api/src/test/java/eu/europa/ec/smp/api/IdentifiersTest.java +++ b/smp-api/src/test/java/eu/europa/ec/smp/api/IdentifiersTest.java @@ -87,8 +87,8 @@ public class IdentifiersTest { Object[] res = new Object[commonTests.length+2]; System.arraycopy(commonTests, 0,res, 0, commonTests.length ); //add new test with empty schema - res[commonTests.length] = new Object[]{"::a","","a"}; - res[commonTests.length+1] = new Object[]{"::urn:ehealth:ncp::pt:ism","","urn:ehealth:ncp::pt:ism"}; + res[commonTests.length] = new Object[]{"::a",null,"a"}; + res[commonTests.length+1] = new Object[]{"::urn:ehealth:ncp::pt:ism",null,"urn:ehealth:ncp::pt:ism"}; return res; } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ServiceMetadataDao.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ServiceMetadataDao.java index 2651e82882f7cc5bdf0e2dbf67530a1d3d8717a5..37f44a5fad879b4c472a976baffc9efa4ecfbf08 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ServiceMetadataDao.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/dao/ServiceMetadataDao.java @@ -48,7 +48,7 @@ public class ServiceMetadataDao extends BaseDao<DBServiceMetadata> { query.setParameter("partcId", participantId); query.setParameter("partcSch", participantSchema); query.setParameter("docId", documentId); - query.setParameter("docSch", documentSchema==null?"":documentSchema); + query.setParameter("docSch", documentSchema); DBServiceMetadata res = query.getSingleResult(); return Optional.of(res); } catch (NoResultException e) { diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceMetadataRO.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceMetadataRO.java index dad9a1dd2ab9eab6c4fab0b8a2607c0bc6901a68..c67e073ab2b9f29898f4614ac41c5fb527cdad4a 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceMetadataRO.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/ui/ServiceMetadataRO.java @@ -2,6 +2,7 @@ package eu.europa.ec.edelivery.smp.data.ui; import eu.europa.ec.edelivery.smp.data.ui.enums.EntityROStatus; +import org.apache.commons.lang3.StringUtils; /** * @author Joze Rihtarsic @@ -54,7 +55,8 @@ public class ServiceMetadataRO extends BaseRO { } public String getDocumentIdentifierScheme() { - return documentIdentifierScheme; + + return StringUtils.isEmpty(documentIdentifierScheme)?null: documentIdentifierScheme; } public void setDocumentIdentifierScheme(String documentIdentifierScheme) { diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIUserService.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIUserService.java index d47773cb2914d5d5639cdb0ef32d10d369e47774..c0c875c7c9e1fd41010eb6313071529ac251a3b6 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIUserService.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/services/ui/UIUserService.java @@ -223,7 +223,7 @@ public class UIUserService extends UIServiceBase<DBUser, UserRO> { } /** - * pem encoded cartificate can have header_?? this code finds the certificate part and return the part + * pem encoded certificate can have header_?? this code finds the certificate part and return the part * @param buff * @return */ diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/UserResource.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/UserResource.java index 8fd5eeac096722b846c17f6fc81441318d7532f1..3c8122b11de7d9b8c43023384b1a7f8449a6fe51 100644 --- a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/UserResource.java +++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/UserResource.java @@ -88,7 +88,7 @@ public class UserResource { uiUserService.updateUserList(Arrays.asList(updateEntities)); } - @PostMapping("/{id}/certdata") + @PostMapping(value = "/{id}/certdata" ,produces = {"application/json"},consumes = {"application/octet-stream"}) @PreAuthorize("@smpAuthorizationService.systemAdministrator || @smpAuthorizationService.isCurrentlyLoggedIn(#id)") public CertificateRO uploadFile(@PathVariable("id") Long id, @RequestBody byte[] data) { LOG.info("Got certificate data: " + data.length);