use of org.eclipse.dataspaceconnector.spi.types.domain.DataAddress in project DataSpaceConnector by eclipse-dataspaceconnector.
the class ObjectStorageDefinitionConsumerGenerator method generate.
@Override
@Nullable
public ResourceDefinition generate(TransferProcess process) {
var request = process.getDataRequest();
if (request.getDataDestination() == null || request.getDestinationType() == null || !AzureBlobStoreSchema.TYPE.equals(request.getDestinationType())) {
return null;
}
DataAddress destination = request.getDataDestination();
String id = randomUUID().toString();
var account = destination.getProperty(AzureBlobStoreSchema.ACCOUNT_NAME);
var container = destination.getProperty(AzureBlobStoreSchema.CONTAINER_NAME);
if (container == null) {
container = randomUUID().toString();
}
return ObjectStorageResourceDefinition.Builder.newInstance().id(id).accountName(account).containerName(container).build();
}
use of org.eclipse.dataspaceconnector.spi.types.domain.DataAddress in project DataSpaceConnector by eclipse-dataspaceconnector.
the class S3ResourceDefinitionConsumerGenerator method generate.
@Override
public ResourceDefinition generate(TransferProcess process) {
var request = process.getDataRequest();
if (request.getDestinationType() != null) {
if (!S3BucketSchema.TYPE.equals(request.getDestinationType())) {
return null;
}
// FIXME generate region from policy engine
return S3BucketResourceDefinition.Builder.newInstance().id(randomUUID().toString()).bucketName(process.getId()).regionId(Region.US_EAST_1.id()).build();
} else if (request.getDataDestination() == null || !(request.getDataDestination().getType().equals(S3BucketSchema.TYPE))) {
return null;
}
DataAddress destination = request.getDataDestination();
String id = randomUUID().toString();
return S3BucketResourceDefinition.Builder.newInstance().id(id).bucketName(destination.getProperty(S3BucketSchema.BUCKET_NAME)).regionId(destination.getProperty(S3BucketSchema.REGION)).build();
}
use of org.eclipse.dataspaceconnector.spi.types.domain.DataAddress in project DataSpaceConnector by eclipse-dataspaceconnector.
the class ObjectStorageDefinitionConsumerGeneratorTest method generate.
@Test
void generate() {
DataAddress destination = DataAddress.Builder.newInstance().type(AzureBlobStoreSchema.TYPE).property(AzureBlobStoreSchema.CONTAINER_NAME, "test-container").property(AzureBlobStoreSchema.ACCOUNT_NAME, "test-account").build();
var asset = Asset.Builder.newInstance().build();
var dr = DataRequest.Builder.newInstance().dataDestination(destination).assetId(asset.getId()).build();
var tp = TransferProcess.Builder.newInstance().dataRequest(dr).id(randomUUID().toString()).build();
ResourceDefinition def = generator.generate(tp);
assertThat(def).isInstanceOf(ObjectStorageResourceDefinition.class);
var objectDef = (ObjectStorageResourceDefinition) def;
assertThat(objectDef.getAccountName()).isEqualTo("test-account");
assertThat(objectDef.getContainerName()).isEqualTo("test-container");
assertThat(objectDef.getId()).matches(regexPattern);
}
use of org.eclipse.dataspaceconnector.spi.types.domain.DataAddress in project DataSpaceConnector by eclipse-dataspaceconnector.
the class ObjectStorageConsumerResourceDefinitionGeneratorTest method generate_containerIsNull.
@Test
void generate_containerIsNull() {
DataAddress destination = DataAddress.Builder.newInstance().type(AzureBlobStoreSchema.TYPE).property(AzureBlobStoreSchema.ACCOUNT_NAME, "test-account").build();
var asset = Asset.Builder.newInstance().build();
var dataRequest = DataRequest.Builder.newInstance().dataDestination(destination).assetId(asset.getId()).build();
var policy = Policy.Builder.newInstance().build();
var definition = generator.generate(dataRequest, policy);
assertThat(definition).isNotNull();
assertThat(((ObjectStorageResourceDefinition) definition).getContainerName()).matches(regexPattern);
}
use of org.eclipse.dataspaceconnector.spi.types.domain.DataAddress in project DataSpaceConnector by eclipse-dataspaceconnector.
the class CosmosAssetIndexIntegrationTest method queryAssets_selectAll.
@Test
void queryAssets_selectAll() {
Asset asset1 = createAsset("123", "hello", "world");
Asset asset2 = createAsset("456", "foo", "bar");
container.createItem(new AssetDocument(asset1, TEST_PARTITION_KEY, dataAddress));
container.createItem(new AssetDocument(asset2, TEST_PARTITION_KEY, dataAddress));
List<Asset> assets = assetIndex.queryAssets(AssetSelectorExpression.SELECT_ALL).collect(Collectors.toList());
assertThat(assets).hasSize(2).anyMatch(asset -> asset.getProperties().equals(asset1.getProperties())).anyMatch(asset -> asset.getProperties().equals(asset2.getProperties()));
}
Aggregations