diff --git a/src/modules/app/app.module.ts b/src/modules/app/app.module.ts index c482e8c1d..b46ae083c 100644 --- a/src/modules/app/app.module.ts +++ b/src/modules/app/app.module.ts @@ -68,6 +68,10 @@ import {environment} from "../../environments/environment"; provide: 'STORAGE_TYPES', useFactory: () => [{id: "AzureStorage", name: "AzureStorage"}, {id: "AmazonS3", name: "AmazonS3"}], }, + { + provide: 'AWS_REGIONS', + useFactory: () => ["us-east-1", "us-east-2", "us-west-1", "us-west-2", "ap-south-1", "ap-northeast-3", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-northeast-1", "ca-central-1", "eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "eu-north-1", "sa-east-1", "af-south-1", "ap-east-1", "ap-south-2", "ap-southeast-3", "eu-south-1", "eu-south-2", "eu-central-2", "me-south-1", "me-central-1"], + }, { provide: Configuration, useFactory: (s: AppConfigService) => { diff --git a/src/modules/edc-demo/components/asset-editor-dialog/asset-editor-dialog.component.html b/src/modules/edc-demo/components/asset-editor-dialog/asset-editor-dialog.component.html index d46bcab78..9087f090e 100644 --- a/src/modules/edc-demo/components/asset-editor-dialog/asset-editor-dialog.component.html +++ b/src/modules/edc-demo/components/asset-editor-dialog/asset-editor-dialog.component.html @@ -24,7 +24,7 @@
Destination - + {{storageType.name}} @@ -32,18 +32,26 @@ - Account - + Region + Account + + + + {{awsRegion}} + + - Container - + Bucket Name + Container Name + - Blob Name - + Key Name + Blob Name +
diff --git a/src/modules/edc-demo/components/asset-editor-dialog/asset-editor-dialog.component.ts b/src/modules/edc-demo/components/asset-editor-dialog/asset-editor-dialog.component.ts index 0affd6929..1bcbaeca2 100644 --- a/src/modules/edc-demo/components/asset-editor-dialog/asset-editor-dialog.component.ts +++ b/src/modules/edc-demo/components/asset-editor-dialog/asset-editor-dialog.component.ts @@ -17,38 +17,66 @@ export class AssetEditorDialog implements OnInit { contenttype: string = ''; storageTypeId: string = 'AzureStorage'; - account: string = ''; - container: string = 'src-container'; - blobname: string = ''; + // Azure Account or AWS Region (dependent on selected storage type) + param1: string = ''; + + // Azure Container or AWS S3 Bucket (dependent on selected storage type) + param2: string = 'src-container'; + + //Azure Blob Name or AWS S3 Object Key (dependent on selected storage type) + param3: string = ''; constructor(private assetService: AssetService, private dialogRef: MatDialogRef, - @Inject('STORAGE_TYPES') public storageTypes: StorageType[]) { + @Inject('AWS_REGIONS') public awsRegions: string[], @Inject('STORAGE_TYPES') public storageTypes: StorageType[]) { } ngOnInit(): void { } onSave() { - const assetEntryDto: AssetEntryDto = { - asset: { - properties: { - "asset:prop:name": this.name, - "asset:prop:version": this.version, - "asset:prop:id": this.id, - "asset:prop:contenttype": this.contenttype, - } - }, - dataAddress: { - properties: { - "type": this.storageTypeId, - "account": this.account, - "container": this.container, - "blobname": this.blobname, - "keyName": `${this.account}-key1` + if(this.storageTypeId=='AzureStorage'){ + const assetEntryDto: AssetEntryDto = { + asset: { + properties: { + "asset:prop:name": this.name, + "asset:prop:version": this.version, + "asset:prop:id": this.id, + "asset:prop:contenttype": this.contenttype, + } }, - } - }; + dataAddress: { + properties: { + "type": this.storageTypeId, + "account": this.param1, + "container": this.param2, + "blobname": this.param3, + "keyName": `${this.param1}-key1` + }, + } + }; - this.dialogRef.close({ assetEntryDto }); + this.dialogRef.close({ assetEntryDto }); + }else if(this.storageTypeId=='AmazonS3'){ + const assetEntryDto: AssetEntryDto = { + asset: { + properties: { + "asset:prop:name": this.name, + "asset:prop:version": this.version, + "asset:prop:id": this.id, + "asset:prop:contenttype": this.contenttype, + } + }, + dataAddress: { + properties: { + "type": this.storageTypeId, + "region": this.param1, + "bucketName": this.param2, + "keyName": this.param3 + }, + } + }; + + this.dialogRef.close({ assetEntryDto }); + } } } diff --git a/src/modules/edc-demo/components/catalog-browser-transfer-dialog/catalog-browser-transfer-dialog.component.html b/src/modules/edc-demo/components/catalog-browser-transfer-dialog/catalog-browser-transfer-dialog.component.html index be3be07a4..7999b143c 100644 --- a/src/modules/edc-demo/components/catalog-browser-transfer-dialog/catalog-browser-transfer-dialog.component.html +++ b/src/modules/edc-demo/components/catalog-browser-transfer-dialog/catalog-browser-transfer-dialog.component.html @@ -1,14 +1,40 @@ +
+ + Destination + + + {{storageType.name}} + + + +
- - Destination - - - {{storageType.name}} - - - +
+ + Region + + + {{awsRegion}} + + + +
+ +
+ + Account + + +
+
+ + Bucket + Container Name + + +
diff --git a/src/modules/edc-demo/components/catalog-browser-transfer-dialog/catalog-browser-transfer-dialog.component.ts b/src/modules/edc-demo/components/catalog-browser-transfer-dialog/catalog-browser-transfer-dialog.component.ts index 9555bcf04..50964d5b7 100644 --- a/src/modules/edc-demo/components/catalog-browser-transfer-dialog/catalog-browser-transfer-dialog.component.ts +++ b/src/modules/edc-demo/components/catalog-browser-transfer-dialog/catalog-browser-transfer-dialog.component.ts @@ -11,9 +11,16 @@ import {StorageType} from '../../models/storage-type'; export class CatalogBrowserTransferDialog implements OnInit { name: string = ''; - storageTypeId = ''; + storageTypeId: string = 'AzureStorage'; + + // Azure Account or AWS Region (dependent on selected storage type) + param1: string = ''; + + // Azure Container or AWS S3 Bucket (dependent on selected storage type) + param2: string = ''; constructor(@Inject('STORAGE_TYPES') public storageTypes: StorageType[], + @Inject('AWS_REGIONS') public awsRegions: string[], private dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) contractDefinition?: any) { } @@ -23,7 +30,7 @@ export class CatalogBrowserTransferDialog implements OnInit { onTransfer() { - this.dialogRef.close({storageTypeId: this.storageTypeId}); + this.dialogRef.close({storageTypeId: this.storageTypeId, param1 : this.param1, param2 : this.param2}); } } diff --git a/src/modules/edc-demo/components/contract-viewer/contract-viewer.component.ts b/src/modules/edc-demo/components/contract-viewer/contract-viewer.component.ts index 2ab994bf9..61c7c3476 100644 --- a/src/modules/edc-demo/components/contract-viewer/contract-viewer.component.ts +++ b/src/modules/edc-demo/components/contract-viewer/contract-viewer.component.ts @@ -74,11 +74,10 @@ export class ContractViewerComponent implements OnInit { dialogRef.afterClosed().pipe(first()).subscribe(result => { const storageTypeId: string = result.storageTypeId; - if (storageTypeId !== 'AzureStorage') { - this.notificationService.showError("Only storage type \"AzureStorage\" is implemented currently!") - return; - } - this.createTransferRequest(contract, storageTypeId) + if (storageTypeId == 'AmazonS3') { + const region: string = result.param1; + const bucket: string = result.param2; + this.createTransferRequests3(contract, storageTypeId, region, bucket) .pipe(switchMap(trq => this.transferService.initiateTransfer(trq))) .subscribe(transferId => { this.startPolling(transferId, contract.id!); @@ -86,6 +85,17 @@ export class ContractViewerComponent implements OnInit { console.error(error); this.notificationService.showError("Error initiating transfer"); }); + }else if (storageTypeId == 'AzureStorage'){ + this.createTransferRequest(contract, storageTypeId) + .pipe(switchMap(trq => this.transferService.initiateTransfer(trq))) + .subscribe(transferId => { + this.startPolling(transferId, contract.id!); + }, error => { + console.error(error); + this.notificationService.showError("Error initiating transfer"); + }); + } + }); } @@ -94,27 +104,77 @@ export class ContractViewerComponent implements OnInit { } private createTransferRequest(contract: ContractAgreementDto, storageTypeId: string): Observable { - return this.getOfferedAssetForId(contract.assetId!).pipe(map(offeredAsset => { - return { - assetId: offeredAsset.id, - contractId: contract.id, - connectorId: "consumer", //doesn't matter, but cannot be null - dataDestination: { - properties: { - "type": storageTypeId, - account: this.homeConnectorStorageAccount, // CAUTION: hardcoded value for AzureBlob - // container: omitted, so it will be auto-assigned by the EDC runtime - } - }, - managedResources: true, - transferType: {isFinite: true}, //must be there, otherwise NPE on backend - connectorAddress: offeredAsset.originator, - protocol: 'ids-multipart' - }; - })); + return this.getOfferedAssetForId(contract.assetId!).pipe(map(offeredAsset => { + return { + assetId: offeredAsset.id, + contractId: contract.id, + connectorId: "consumer", //doesn't matter, but cannot be null + dataDestination: { + properties: { + "type": storageTypeId, + account: this.homeConnectorStorageAccount, // CAUTION: hardcoded value for AzureBlob + // container: omitted, so it will be auto-assigned by the EDC runtime + } + }, + managedResources: true, + transferType: {isFinite: true}, //must be there, otherwise NPE on backend + connectorAddress: offeredAsset.originator, + protocol: 'ids-multipart' + }; + })); + } + private createTransferRequests3(contract: ContractAgreementDto, storageTypeId: string, region: string, bucket: string): Observable { + + if (region && bucket) { + return this.getOfferedAssetForId(contract.assetId!).pipe(map(offeredAsset => { + return { + assetId: offeredAsset.id, + contractId: contract.id, + connectorId: "consumer", //doesn't matter, but cannot be null + dataDestination: { + properties: { + type: "AmazonS3", + region: region, + bucketName: bucket, + }, + type: "AmazonS3" + }, + managedResources: true, + transferType: { + isFinite: true + }, //must be there, otherwise NPE on backend + connectorAddress: offeredAsset.originator, + protocol: 'ids-multipart' + }; + })); + }else{ + return this.getOfferedAssetForId(contract.assetId!).pipe(map(offeredAsset => { + return { + assetId: offeredAsset.id, + contractId: contract.id, + connectorId: "consumer", //doesn't matter, but cannot be null + dataDestination: { + properties: { + type: "AmazonS3", + region: "eu-west-1", + }, + type: "AmazonS3" + }, + managedResources: true, + transferType: { + isFinite: true + }, //must be there, otherwise NPE on backend + connectorAddress: offeredAsset.originator, + protocol: 'ids-multipart' + }; + })); + } + +} + /** * This method is used to obtain that URL of the connector that is offering a particular asset from the catalog. * This is a bit of a hack, because currently there is no "clean" way to get the counter-party's URL for a ContractAgreement.