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

Fix: Speedup of file listing

parent 9be4ef29
Branches
Tags
No related merge requests found
......@@ -40,6 +40,26 @@ namespace TrellisMigrator.Implementations
return graphs;
}
public IEnumerable<Uri> ListFileGraphs(string id)
{
var cmdString = new SparqlParameterizedString
{
CommandText = @"SELECT DISTINCT ?g
WHERE { GRAPH ?g { ?s a <http://purl.org/fdp/fdp-o#MetadataService> }
FILTER(contains(str(?g), @graph)) }"
};
cmdString.SetLiteral("graph", id);
var resultSet = QueryEndpoint.QueryWithResultSet(cmdString.ToString());
var graphs = new List<Uri>();
foreach (SparqlResult r in resultSet)
{
graphs.Add((r.Value("g") as UriNode)?.Uri);
}
return graphs;
}
public override IEnumerable<IGraph> ConvertToLinkedData(IEnumerable<Resource> entries)
{
var graph = WrapRequest(() => GetGraph("http://www.trellisldp.org/ns/trellis#PreferServerManaged"));
......@@ -98,7 +118,7 @@ namespace TrellisMigrator.Implementations
AddModifiedDate(graph, dctermsModifiedNode, baseNode);
}
var fileGraphs = WrapRequest(() => ListGraphs(resourceGraphName + "/"));
var fileGraphs = WrapRequest(() => ListFileGraphs(resourceGraphName + "/"));
foreach (var fileGraph in fileGraphs)
{
if (fileGraph.ToString() != resourceGraphName + "/")
......@@ -125,8 +145,10 @@ namespace TrellisMigrator.Implementations
var resourceACLGraphName = $"{resourceUrlPrefix}/{entry.Id}?ext=acl";
var entryAlreadyExists = WrapRequest(() => HasGraph(resourceACLGraphName));
if (!entryAlreadyExists)
{
var resourceGraphExists = WrapRequest(() => HasGraph(resourceGraphName));
if (!entryAlreadyExists && resourceGraphExists)
if (resourceGraphExists)
{
var resourceGraph = WrapRequest(() => GetGraph(resourceGraphName));
var aclSubjects = resourceGraph.GetTriplesWithObject(new Uri("http://www.w3.org/ns/auth/acl#Authorization")).Select((triple) => triple.Subject);
......@@ -152,6 +174,7 @@ namespace TrellisMigrator.Implementations
graphs.Add(aclGraph);
}
}
}
return graphs;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment