Skip to content

Commit

Permalink
get recursive archival group
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcrane committed Dec 21, 2023
1 parent 680349b commit fa25a63
Show file tree
Hide file tree
Showing 13 changed files with 306 additions and 26 deletions.
3 changes: 2 additions & 1 deletion LeedsExperiment/Fedora/ApiModel/BinaryMetadataResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ public class BinaryMetadataResponse : FedoraJsonLdResponse
[JsonPropertyOrder(202)]
public string? ContentType { get; set; }

// This comes back as a string
[JsonPropertyName("hasSize")]
[JsonPropertyOrder(203)]
public long Size { get; set; }
public string Size { get; set; }

[JsonPropertyName("hasMessageDigest")]
[JsonPropertyOrder(211)]
Expand Down
5 changes: 5 additions & 0 deletions LeedsExperiment/Fedora/ArchivalGroup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Fedora.ApiModel;
using Fedora.Storage;

namespace Fedora;

Expand All @@ -9,6 +10,10 @@ public ArchivalGroup(FedoraJsonLdResponse fedoraResponse) : base(fedoraResponse)

}

public StorageMap? StorageMap { get; set; }

public Storage.Version[] Versions { get; set; }

public Uri GetResourceUri(string path)
{
// the Location property won't end with a trailing slash, so we can't create URIs with the normal Uri constructor
Expand Down
5 changes: 5 additions & 0 deletions LeedsExperiment/Fedora/Binary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@ public string Origin
public string? ContentType { get; set; }
public long Size { get; set; }
public string? Digest { get; set; }

public override string ToString()
{
return $"🗎 {Name ?? GetType().Name}";
}
}
}
7 changes: 7 additions & 0 deletions LeedsExperiment/Fedora/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ public Container(FedoraJsonLdResponse jsonLdResponse) : base(jsonLdResponse)
{
}

public bool Populated { get; set; } = false;

public required List<Container> Containers { get; set; } = new List<Container>();
public required List<Binary> Binaries { get; set; } = new List<Binary>();

public override string ToString()
{
return $"📁 {Name ?? GetType().Name}";
}
}
}
3 changes: 3 additions & 0 deletions LeedsExperiment/Fedora/IFedora.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public interface IFedora
Task<T?> GetObject<T>(Uri uri, Transaction? transaction = null) where T: Resource;
Task<T?> GetObject<T>(string path, Transaction? transaction = null) where T : Resource;

Task<ArchivalGroup?> GetPopulatedArchivalGroup(Uri uri, string? version = null, Transaction? transaction = null);
Task<ArchivalGroup?> GetPopulatedArchivalGroup(string path, string? version = null, Transaction? transaction = null);

Task<ArchivalGroup?> CreateArchivalGroup(Uri parent, string slug, string name, Transaction? transaction = null);
Task<ArchivalGroup?> CreateArchivalGroup(string parentPath, string slug, string name, Transaction? transaction = null);
Task<Container?> CreateContainer(Uri parent, string slug, string name, Transaction? transaction = null);
Expand Down
8 changes: 8 additions & 0 deletions LeedsExperiment/Fedora/IStorageMapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Fedora.Storage;

namespace Fedora;

public interface IStorageMapper
{
Task<StorageMap> GetStorageMap(ArchivalGroup archivalGroup, string? version = null);
}
24 changes: 24 additions & 0 deletions LeedsExperiment/Fedora/Storage/StorageMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Fedora.Storage;

public class StorageMap
{
// v1, v2
public string Version { get; set; }

// e.g., S3
public string StorageType { get; set; }

// e.g., a bucket
public string Root { get; set; }

// The key of the object container
public string ObjectPath { get; set; }

public Dictionary<string, OriginFile> Files { get; set; }
}

public class OriginFile
{
public string Hash { get; set; }
public string FullPath { get; set; }
}
8 changes: 8 additions & 0 deletions LeedsExperiment/Fedora/Storage/Version.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Fedora.Storage;

public class Version
{
public string MementoTimestamp { get; set; }
public DateTime LastModified { get; set; }
public string OcflVersion { get; set; }
}
Loading

0 comments on commit fa25a63

Please sign in to comment.