Skip to content

Commit

Permalink
Merge branch 'release/2.24.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Jun 4, 2024
2 parents fe1ba0d + e7f17f3 commit 186c828
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 5 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

## [2.24.0](https://github.com/Terradue/Stars/compare/2.23.0...2.24.0)
## [2.24.1](https://github.com/Terradue/Stars/compare/2.24.0...2.24.1)

### Commits

- Refactor StacStoreService to improve asset URI handling in collection [`78358a5`](https://github.com/Terradue/Stars/commit/78358a5e23252b92c562b277561af6354d1d1bab)

## [2.24.0](https://github.com/Terradue/Stars/compare/2.23.0...2.24.0) - 2024-06-04

### Commits

Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Console/Terradue.Stars.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net6.0</TargetFrameworks>
<Version>2.24.0</Version>
<Version>2.24.1</Version>
<!-- <VersionSuffix>beta.8</VersionSuffix> -->
<Description>Stars is a CLI for working with Spatio Temporal Catalog such as STAC but not only</Description>
<Version Condition=" '$(VersionSuffix)' != '' ">$(Version)-$(VersionSuffix)</Version>
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Data/Terradue.Stars.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ProjectName>Terradue.Stars.Data</ProjectName>
<Title>Terradue.Stars.Data</Title>
<Description>Collection of data Plugins for Terradue.Stars</Description>
<Version>2.24.0</Version>
<Version>2.24.1</Version>
<!-- <VersionSuffix>beta.8</VersionSuffix> -->
<Version Condition=" '$(VersionSuffix)' != '' ">$(Version)-$(VersionSuffix)</Version>
<NoWarn>NU1603</NoWarn>
Expand Down
51 changes: 50 additions & 1 deletion src/Stars.Services/Store/StacStoreService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public async Task<StacItemNode> StoreItemNodeAtDestinationAsync(StacItemNode sta

public async Task<StacCollectionNode> StoreCollectionNodeAtDestinationAsync(StacCollectionNode stacCollectionNode, IDestination destination, CancellationToken ct)
{
PrepareStacCatalogueForDestination(stacCollectionNode, destination);
PrepareStacCollectionForDestination(stacCollectionNode, destination);
return await _stacRouter.RouteAsync(await StoreResourceAtDestinationAsync(stacCollectionNode, destination, ct), ct) as StacCollectionNode;
}

Expand Down Expand Up @@ -305,6 +305,16 @@ private void PrepareStacCatalogueForDestination(StacCatalogNode stacCatalogNode,
PrepareStacNodeForDestination(stacCatalogNode, destination);
}

private void PrepareStacCollectionForDestination(StacCollectionNode stacCollectionNode, IDestination destination)
{
PrepareStacNodeForDestination(stacCollectionNode, destination);
if (storeOptions.AbsoluteAssetsUrl)
MakeAssetUriAbsolute(stacCollectionNode, destination);
else
MakeAssetUriRelative(stacCollectionNode, destination);
}


public void PrepareStacItemForDestination(StacItemNode stacItemNode, IDestination destination)
{
PrepareStacNodeForDestination(stacItemNode, destination);
Expand All @@ -327,6 +337,16 @@ private void MakeAssetUriAbsolute(StacItemNode stacItemNode, IDestination destin
}
}

private void MakeAssetUriAbsolute(StacCollectionNode stacCollectionNode, IDestination destination)
{
MakeAssetUriRelative(stacCollectionNode, destination);
foreach (var asset in stacCollectionNode.StacCollection.Assets)
{
if (asset.Value.Uri.IsAbsoluteUri) continue;
asset.Value.Uri = new Uri(MapToFrontUri(destination.Uri), asset.Value.Uri);
}
}

private void MakeAssetUriRelative(StacItemNode stacItemNode, IDestination destination)
{
foreach (var asset in stacItemNode.StacItem.Assets)
Expand Down Expand Up @@ -356,6 +376,35 @@ private void MakeAssetUriRelative(StacItemNode stacItemNode, IDestination destin
}
}

private void MakeAssetUriRelative(StacCollectionNode stacCollectionNode, IDestination destination)
{
foreach (var asset in stacCollectionNode.StacCollection.Assets)
{
if (!asset.Value.Uri.IsAbsoluteUri) continue;
// 0. make sure the uri is not outside of the root catalog
var relativeUri = RootCatalogDestination.Uri.MakeRelativeUri(asset.Value.Uri);
if (relativeUri.IsAbsoluteUri || relativeUri.ToString().StartsWith("../"))
continue;
// 1. Check the asset uri can be relative to destination itself
relativeUri = destination.Uri.MakeRelativeUri(asset.Value.Uri);
if (!relativeUri.IsAbsoluteUri)
{
asset.Value.Uri = relativeUri;
continue;
}
// 1. Check the asset uri can be relative to root catalog
relativeUri = RootCatalogDestination.Uri.MakeRelativeUri(asset.Value.Uri);
if (relativeUri.IsAbsoluteUri) continue;
Uri absoluteUri = new Uri(RootCatalogNode.Uri, relativeUri);
relativeUri = stacCollectionNode.Uri.MakeRelativeUri(asset.Value.Uri);
if (!relativeUri.IsAbsoluteUri)
{
asset.Value.Uri = relativeUri;
continue;
}
}
}

public async Task<IAssetsContainer> GetAssetsInFolderAsync(string relPath, CancellationToken ct)
{
return await resourceServiceProvider.GetAssetsInFolderAsync(new GenericResource(new Uri(RootCatalogDestination.Uri, relPath)), ct);
Expand Down
2 changes: 1 addition & 1 deletion src/Stars.Services/Terradue.Stars.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Title>Terradue.Stars</Title>
<Description>Stars is a set of services for working with Spatio Temporal Catalog such as STAC but not only</Description>
<Version>2.24.0</Version>
<Version>2.24.1</Version>
<!-- <VersionSuffix>beta.8</VersionSuffix> -->
<Version Condition=" '$(VersionSuffix)' != '' ">$(Version)-$(VersionSuffix)</Version>
<AssemblyName>Terradue.Stars.Services</AssemblyName>
Expand Down

0 comments on commit 186c828

Please sign in to comment.