Skip to content
Snippets Groups Projects
Commit bfa244a0 authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Use new Id

parent a0b87f1e
No related branches found
No related tags found
1 merge request!77New: Use the new metadata structure (coscine/issues#1792)
...@@ -6,6 +6,7 @@ using Coscine.Database.Models; ...@@ -6,6 +6,7 @@ using Coscine.Database.Models;
using Coscine.Database.Util; using Coscine.Database.Util;
using Coscine.Logging; using Coscine.Logging;
using Coscine.Metadata; using Coscine.Metadata;
using Coscine.Metadata.Util;
using Coscine.ResourceTypes; using Coscine.ResourceTypes;
using Coscine.ResourceTypes.Base.Models; using Coscine.ResourceTypes.Base.Models;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
...@@ -61,9 +62,39 @@ namespace Coscine.Api.Blob.Controllers ...@@ -61,9 +62,39 @@ namespace Coscine.Api.Blob.Controllers
/// </summary> /// </summary>
/// <param name="resourceId">Id of the resource</param> /// <param name="resourceId">Id of the resource</param>
/// <param name="path">Path to file</param> /// <param name="path">Path to file</param>
/// <param name="retrieve">Is retrieve action?</param>
/// <returns> Uri </returns> /// <returns> Uri </returns>
public Uri GenerateId(string resourceId, string path) public Uri GenerateId(string resourceId, string path, bool retrieve = false)
{ {
if (!path.StartsWith("/"))
{
path = "/" + path;
}
var currentId = _rdfStoreConnector.GetMetadataId(resourceId, path);
if (currentId == null && retrieve)
{
return GenerateOldId(resourceId, path);
}
var newVersionGraph = new CustomUri($"https://purl.org/coscine/resources/{resourceId}{path}/@type=metadata&version={VersionUtil.GetNewVersion()}");
return newVersionGraph;
}
/// <summary>
/// Generates Id
/// </summary>
/// <param name="resourceId">Id of the resource</param>
/// <param name="path">Path to file</param>
/// <returns> Uri </returns>
public Uri GenerateOldId(string resourceId, string path)
{
if (!path.StartsWith("/"))
{
path = "/" + path;
}
return new CustomUri($"https://hdl.handle.net/{_prefix}/{resourceId}@path={Uri.EscapeDataString(path)}"); return new CustomUri($"https://hdl.handle.net/{_prefix}/{resourceId}@path={Uri.EscapeDataString(path)}");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment