Skip to content
Snippets Groups Projects
Commit d1bc7ffe authored by Petar Hristov's avatar Petar Hristov :speech_balloon:
Browse files

Merge branch 'Issue/1792-newMetadataStructure' into 'dev'

New: Use the new metadata structure (coscine/issues#1792)

See merge request !77
parents 80c2c8f2 f3865a3e
No related branches found
No related tags found
2 merge requests!86Release: Sprint/2023 04 :robot:,!77New: Use the new metadata structure (coscine/issues#1792)
# Blob API
This API handles the connection to the data stored in Coscine.
This API handles the connection to the research data stored in Coscine.
Metadata has to have been provided, before storing of research data can proceed.
Check out the [docs](https://coscine.rwth-aachen.de/coscine/api/Coscine.Api.Blob/swagger).
using Coscine.Api.Blob.Util;
using Coscine.ApiCommons;
using Coscine.Configuration;
using Coscine.Database.DataModel;
......@@ -36,6 +35,7 @@ namespace Coscine.Api.Blob.Controllers
private readonly CoscineLogger _coscineLogger;
private readonly AnalyticsLogObject _analyticsLogObject;
private readonly RdfStoreConnector _rdfStoreConnector;
private readonly CoscineLDPHelper _coscineLDPHelper;
private readonly string _prefix;
/// <summary>
......@@ -54,17 +54,7 @@ namespace Coscine.Api.Blob.Controllers
_coscineLogger = new CoscineLogger(logger);
_analyticsLogObject = new AnalyticsLogObject();
_prefix = _configuration.GetStringAndWait("coscine/global/epic/prefix");
}
/// <summary>
/// Generates Id
/// </summary>
/// <param name="resourceId">Id of the resource</param>
/// <param name="path"> Path to file</param>
/// <returns> Uri </returns>
public Uri GenerateId(string resourceId, string path)
{
return new CustomUri($"https://hdl.handle.net/{_prefix}/{resourceId}@path={Uri.EscapeDataString(path)}");
_coscineLDPHelper = new CoscineLDPHelper(_rdfStoreConnector, _prefix);
}
/// <summary>
......@@ -225,7 +215,7 @@ namespace Coscine.Api.Blob.Controllers
return BadRequest("Only one file can be uploaded per request.");
}
var id = GenerateId(resourceId, $"/{path}");
var id = _coscineLDPHelper.GetId(resourceId, $"/{path}", true);
if (!_rdfStoreConnector.HasGraph(id))
{
return StatusCode((int)HttpStatusCode.Forbidden,
......
using System;
namespace Coscine.Api.Blob.Util
{
/// <summary>
/// Adapts the returned ToString of a Uri
/// </summary>
public class CustomUri : Uri
{
/// <summary>
/// Constructs a Custom Uri
/// </summary>
/// <param name="uri"></param>
public CustomUri(string uri) : base(uri)
{
}
/// <summary>
/// Overwrites the ToString for returning the AbsoluteUri (for dotNetRDF)
/// </summary>
/// <returns></returns>
public override string ToString()
{
return AbsoluteUri;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment