Skip to content

Commit

Permalink
Further renaming for Storage API in prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcrane committed Aug 17, 2024
1 parent 971f3c5 commit 07687ab
Show file tree
Hide file tree
Showing 76 changed files with 159 additions and 174 deletions.
18 changes: 9 additions & 9 deletions LeedsExperiment/Dashboard/Controllers/BrowseController.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using Fedora.Abstractions;
using Microsoft.AspNetCore.Mvc;
using Preservation;
using Storage;
using Utils;

namespace Dashboard.Controllers;

public class BrowseController : Controller
{
private readonly ILogger<BrowseController> logger;
private readonly IPreservation preservation;
private readonly IStorage storage;

public BrowseController(
IPreservation preservation,
IStorage storage,
ILogger<BrowseController> logger)
{
this.preservation = preservation;
this.storage = storage;
this.logger = logger;
}

Expand All @@ -23,7 +23,7 @@ public BrowseController(
public async Task<IActionResult> IndexAsync(string? path = null)
{
ViewBag.Path = path;
var resource = await preservation.GetResource(path);
var resource = await storage.GetResource(path);
if (resource == null)
{
return NotFound();
Expand All @@ -41,7 +41,7 @@ public async Task<IActionResult> IndexAsync(string? path = null)
}
if (resource.PreservationApiPartOf != null)
{
ViewBag.ArchivalGroupPath = preservation.GetInternalPath(resource.PreservationApiPartOf);
ViewBag.ArchivalGroupPath = storage.GetInternalPath(resource.PreservationApiPartOf);
}
var reqPath = Request.Path.Value?.TrimEnd('/');
if (reqPath.HasText())
Expand Down Expand Up @@ -74,7 +74,7 @@ public async Task<IActionResult> IndexAsync(
}
ViewBag.Path = parentPath;
var path = $"{parentPath.TrimEnd('/')}/{name}";
var parentResource = await preservation.GetResource(parentPath);
var parentResource = await storage.GetResource(parentPath);
if(string.IsNullOrWhiteSpace(name))
{
ViewBag.Problem = $"No name supplied!";
Expand All @@ -91,14 +91,14 @@ public async Task<IActionResult> IndexAsync(
ViewBag.Problem = $"Can't create a container within an Archival Group - use an importJob please!";
return View("Container", parentResource as Container);
}
var info = await preservation.GetResourceInfo(path);
var info = await storage.GetResourceInfo(path);
if (info.Exists)
{
ViewBag.Problem = $"Resource already exists at path {path}";
return View("Container", parentResource as Container);
}

Container newContainer = await preservation.CreateContainer(path);
Container newContainer = await storage.CreateContainer(path);
ViewBag.Parent = "/browse/" + parentPath;


Expand Down
14 changes: 1 addition & 13 deletions LeedsExperiment/Dashboard/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
using Dashboard.Models;
using Microsoft.AspNetCore.Mvc;
using Preservation;
using System.Diagnostics;

namespace Dashboard.Controllers;

public class HomeController : Controller
{
private readonly ILogger<HomeController> logger;
private readonly IPreservation preservation;

public HomeController(
IPreservation preservation,
ILogger<HomeController> logger)
{
this.preservation = preservation;
this.logger = logger;
}

{
public IActionResult Index()
{
return View();
Expand Down
14 changes: 7 additions & 7 deletions LeedsExperiment/Dashboard/Controllers/IIIFController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Preservation;
using Storage;
using Utils;

namespace Dashboard.Controllers
{
public class IIIFController : Controller
{
private readonly ILogger<IIIFController> logger;
private readonly IPreservation preservation;
private readonly IStorage storage;
private readonly IDlcs dlcs;

public IIIFController(
IPreservation preservation,
IStorage storage,
IDlcs dlcs,
ILogger<IIIFController> logger)
{
this.preservation = preservation;
this.storage = storage;
this.logger = logger;
this.dlcs = dlcs;
}
Expand All @@ -43,7 +43,7 @@ public async Task<IActionResult> IndexAsync([FromRoute] string path)
{
ViewBag.Path = path;
var model = new IIIFSyncModel { Path = path };
var getAg = preservation.GetArchivalGroup(path, null);
var getAg = storage.GetArchivalGroup(path, null);
var getDlcsImages = dlcs.GetImagesFromQuery(new ImageQuery { String1 = path });

await Task.WhenAll(getAg, getDlcsImages);
Expand Down Expand Up @@ -74,7 +74,7 @@ public async Task<IActionResult> IndexAsync([FromRoute] string path)
public async Task<IActionResult> SyncAsync([FromRoute] string path)
{
ViewBag.Path = path;
var getAg = preservation.GetArchivalGroup(path, null);
var getAg = storage.GetArchivalGroup(path, null);
var getDlcsImages = dlcs.GetImagesFromQuery(new ImageQuery { String1 = path });
await Task.WhenAll(getAg, getDlcsImages);
ArchivalGroup ag = getAg.Result!;
Expand Down Expand Up @@ -116,7 +116,7 @@ public async Task<IActionResult> SyncAsync([FromRoute] string path)
[EnableCors(PolicyName = "IIIF")]
public async Task<IActionResult> Manifest([FromRoute] string path)
{
var getAg = preservation.GetArchivalGroup(path, null);
var getAg = storage.GetArchivalGroup(path, null);
var getDlcsImages = dlcs.GetImagesFromQuery(new ImageQuery { String1 = path });
await Task.WhenAll(getAg, getDlcsImages);

Expand Down
22 changes: 11 additions & 11 deletions LeedsExperiment/Dashboard/Controllers/ImportExportController.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
using Dashboard.Models;
using Fedora.Abstractions;
using Microsoft.AspNetCore.Mvc;
using Preservation;
using Storage;
using System.Text.Json;

namespace Dashboard.Controllers
{
public class ImportExportController : Controller
{
private readonly ILogger<ImportExportController> logger;
private readonly IPreservation preservation;
private readonly IStorage storage;

public ImportExportController(
IPreservation preservation,
IStorage storage,
ILogger<ImportExportController> logger)
{
this.preservation = preservation;
this.storage = storage;
this.logger = logger;
}

Expand All @@ -27,7 +27,7 @@ public async Task<IActionResult> ExportStartAsync(
[FromQuery] string? version = null)
{
ViewBag.Path = path;
var ag = await preservation.GetArchivalGroup(path, version);
var ag = await storage.GetArchivalGroup(path, version);
if (ag == null)
{
return NotFound();
Expand Down Expand Up @@ -56,7 +56,7 @@ public async Task<IActionResult> ExportExecuteAsync(
[FromRoute] string path,
[FromQuery] string? version = null)
{
var exportResult = await preservation.Export(path, version);
var exportResult = await storage.Export(path, version);
return View("ExportResult", exportResult);
// we could also supply the ag to the model for a richer display but at the expense of longer time
}
Expand All @@ -70,12 +70,12 @@ public async Task<IActionResult> ImportStartAsync(
[FromQuery] string? source = null,
[FromQuery] string? name = null) // name if creating a new one; can't rename atm
{
var resourceInfo = await preservation.GetResourceInfo(path);
var resourceInfo = await storage.GetResourceInfo(path);
var model = new ImportModel { Path = path, ResourceInfo = resourceInfo };
if(resourceInfo.Type == nameof(ArchivalGroup))
{
// This is an update to an existing archival group
var existingAg = await preservation.GetArchivalGroup(path, null);
var existingAg = await storage.GetArchivalGroup(path, null);
model.ArchivalGroup = existingAg;
}
else if (resourceInfo.StatusCode != 404)
Expand All @@ -89,7 +89,7 @@ public async Task<IActionResult> ImportStartAsync(
// we already know where the update file are
// This is only for synchronising with S3; There'll need to be a different route
// for ad hoc construction of an ImportJob (e.g., it's just one deletion).
var importJob = await preservation.GetUpdateJob(path, source);
var importJob = await storage.GetUpdateJob(path, source);
model.ImportJob = importJob;
importJob.ArchivalGroupName = model.ArchivalGroup?.Name ?? model.Name;
return View("ImportJob", model);
Expand Down Expand Up @@ -127,8 +127,8 @@ [FromForm] string importJobString
// But I can make this import job outside the dashboard any way I like.
// Would probably post directly to the Preservation API

var processedJob = await preservation.Import(importJob);
var resultingAg = await preservation.GetArchivalGroup(importJob.ArchivalGroupPath, null);
var processedJob = await storage.Import(importJob);
var resultingAg = await storage.GetArchivalGroup(importJob.ArchivalGroupPath, null);
var model = new ImportModel
{
ImportJob = processedJob,
Expand Down
10 changes: 5 additions & 5 deletions LeedsExperiment/Dashboard/Controllers/OcflController.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using Microsoft.AspNetCore.Mvc;
using Preservation;
using Storage;

namespace Dashboard.Controllers
{
public class OcflController : Controller
{
private readonly ILogger<OcflController> logger;
private readonly IPreservation preservation;
private readonly IStorage storage;

public OcflController(
IPreservation preservation,
IStorage storage,
ILogger<OcflController> logger)
{
this.preservation = preservation;
this.storage = storage;
this.logger = logger;
}

Expand All @@ -23,7 +23,7 @@ public async Task<IActionResult> IndexAsync(
[FromQuery] string? version = null)
{
ViewBag.Path = path;
var ag = await preservation.GetArchivalGroup(path, version);
var ag = await storage.GetArchivalGroup(path, version);
if (ag == null)
{
return NotFound();
Expand Down
4 changes: 2 additions & 2 deletions LeedsExperiment/Dashboard/Dashboard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<ItemGroup>
<ProjectReference Include="..\Dlcs\Dlcs.csproj" />
<ProjectReference Include="..\Fedora\Fedora.csproj" />
<ProjectReference Include="..\PreservationApiClient\PreservationApiClient.csproj" />
<ProjectReference Include="..\Preservation\Preservation.csproj" />
<ProjectReference Include="..\PreservationApiClient\StorageApiClient.csproj" />
<ProjectReference Include="..\Preservation\Storage.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion LeedsExperiment/Dashboard/Models/ImportModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Dashboard.Helpers;
using Fedora.Abstractions;
using Preservation;
using Storage;

namespace Dashboard.Models;

Expand Down
6 changes: 3 additions & 3 deletions LeedsExperiment/Dashboard/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Dlcs;
using Preservation;
using PreservationApiClient;
using Storage;
using StorageApiClient;
using System.Net.Http.Headers;

var builder = WebApplication.CreateBuilder(args);
Expand All @@ -9,7 +9,7 @@
builder.Services.AddControllersWithViews();

// https://learn.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests
builder.Services.AddHttpClient<IPreservation, StorageService>(client =>
builder.Services.AddHttpClient<IStorage, StorageService>(client =>
{
client.BaseAddress = new Uri(builder.Configuration["ApiBaseAddress"]!);
client.DefaultRequestHeaders.Add("Accept", "application/json");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@using Dashboard.Borrowed
@using Dashboard.Helpers
@using Utils
@model Preservation.ExportResult
@model Storage.ExportResult

<div>
<h1 class="display-4">Export Result 📦</h1>
Expand Down
2 changes: 1 addition & 1 deletion LeedsExperiment/Fedora/Abstractions/Transfer/BinaryFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Fedora.Abstractions.Transfer;
public class BinaryFile : ResourceWithParentUri
{
/// <summary>
/// An S3 key, a filesystem path - somewhere accessible to the Preservation API, to import from or export to
/// An S3 key, a filesystem path - somewhere accessible to the Storage API, to import from or export to
/// </summary>
[JsonPropertyName("externalLocation")]
[JsonPropertyOrder(11)]
Expand Down
8 changes: 4 additions & 4 deletions LeedsExperiment/LeedsExperiment.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Storage.API", "Storage.API\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dashboard", "Dashboard\Dashboard.csproj", "{8D0AC003-CEDE-4330-98C4-E3205FDB4267}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Preservation", "Preservation\Preservation.csproj", "{7CB531B6-49AE-4969-ACBF-321E2BC8B179}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Storage", "Preservation\Storage.csproj", "{7CB531B6-49AE-4969-ACBF-321E2BC8B179}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "notes", "notes", "{FFBB9C8F-E3D1-4E42-83A4-C9C8228BC2A7}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -20,11 +20,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SamplesWorker", "SamplesWor
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FedoraTests", "FedoraTests\FedoraTests.csproj", "{DB5452C1-837D-46AE-A5FC-B939818A83CF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PreservationApiClient", "PreservationApiClient\PreservationApiClient.csproj", "{2714D982-D2B2-49CE-98FA-104594A26ABF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StorageApiClient", "PreservationApiClient\StorageApiClient.csproj", "{2714D982-D2B2-49CE-98FA-104594A26ABF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlcs", "Dlcs\Dlcs.csproj", "{881D639B-D611-4962-9C1A-56A76B82FDC4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlcs", "Dlcs\Dlcs.csproj", "{881D639B-D611-4962-9C1A-56A76B82FDC4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Preservation.API", "Preservation.API\Preservation.API.csproj", "{65F1F519-256D-4C11-B3F8-53F5779113EE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Preservation.API", "Preservation.API\Preservation.API.csproj", "{65F1F519-256D-4C11-B3F8-53F5779113EE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics.CodeAnalysis;

namespace Preservation.API;
namespace Storage.API;

public static class ArchivalGroupUriHelpers
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
using Amazon.S3.Model;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Preservation.API.Data;
using Preservation.API.Data.Entities;
using Preservation.API.Models;
using Preservation.API.Services;
using Preservation.API.Services.Exporter;
using Storage.API.Data;
using Storage.API.Data.Entities;
using Storage.API.Models;
using Storage.API.Services;
using Storage.API.Services.Exporter;

namespace Preservation.API.Controllers;
namespace Storage.API.Controllers;

[Route("[controller]")]
[ApiController]
Expand Down
Loading

0 comments on commit 07687ab

Please sign in to comment.