Aufgrund einer Wartung wird GitLab am 29.10. zwischen 9:00 und 10:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 29.10. between 9:00 and 10:00 am.

Commit 5fe6f155 authored by Benedikt Heinrichs's avatar Benedikt Heinrichs

Fix: Graphs with special characters now work (coscine/issues#626)

parent 9c7c9a56
......@@ -112,7 +112,8 @@ namespace Coscine.Api.Project.Controllers
if (_resourceModel.HasAccess(user, resource, UserRoles.Owner, UserRoles.Member))
{
var id = _metadataModel.GenerateId(resourceId, filename, version);
var graph = _util.GetGraph(id);
var uri = _metadataModel.CreateUri(id);
var graph = _util.GetGraph(uri);
return Json(JToken.Parse(VDS.RDF.Writing.StringWriter.Write(graph, new RdfJsonWriter())).ToString());
}
else
......@@ -126,7 +127,7 @@ namespace Coscine.Api.Project.Controllers
{
var innerBlock = ObjectFactory<JToken>.DeserializeFromStream(Request.Body);
var graphName = _metadataModel.GenerateId(resourceId, filename, version);
var graphNameUri = new Uri(graphName);
var graphNameUri = _metadataModel.CreateUri(graphName);
var json = new JObject
{
[graphName] = innerBlock
......
......@@ -5,6 +5,7 @@ using LinqToDB;
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
namespace Coscine.Api.Project.Models
{
......@@ -50,7 +51,15 @@ namespace Coscine.Api.Project.Models
public string GenerateId(string resourceId, string filename, string version)
{
return $"https://purl.org/coscine/md/{resourceId}/{filename}/{version}/";
// Double UrlEncode since converting it to Uri executes one UrlDecode and Virtuoso
// graph names don't support special characters
var encodedFileName = HttpUtility.UrlEncode(HttpUtility.UrlEncode(filename));
return $"https://purl.org/coscine/md/{resourceId}/{encodedFileName}/{version}/";
}
public Uri CreateUri(string graphName)
{
return new Uri(graphName);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment