Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • Fix/xxxx-activateGitlab
  • Fix/xxxx-resourceVisibility
  • Hotfix/0071-fixResourceCreate
  • Hotfix/1259-pathParameterFix
  • Hotfix/1260-fixUrl
  • Hotfix/1357-ymlFile
  • Hotfix/1370-swaggerDescription
  • Hotfix/1584-fixResourceLoader
  • Hotfix/1616-repairLinkedResources
  • Hotfix/1634-limitConsulCalls
  • Hotfix/1668-versionResourceConfigDepVersion
  • Hotfix/1681-fixLargeFileSizeQuery
  • Hotfix/1805-listingBreaks
  • Hotfix/2087-efNet6
  • Hotfix/2104-failedUpload
  • Hotfix/2141-fileUploadErrors
  • Hotfix/2233-fixMe
  • Hotfix/2254-fixContentLenghtCalculation
  • Hotfix/2296-selectedValuesNotReturned
  • Hotfix/2307-noLinkedTimeout
  • Hotfix/2313-fixModifiedDate
  • Hotfix/2365-targetClassWorks
  • Hotfix/2371-fixGitLabinRCV
  • Hotfix/2384-guestsAndLinked
  • Hotfix/2452-linkedDeletion
  • Hotfix/2459-EncodingPath
  • Hotfix/2504-formGen
  • Hotfix/64-releaseUDE
  • Issue/1741-semanticSearchActions
  • Issue/1792-newMetadataStructure
  • Issue/1804-fixedValueFix
  • Issue/1866-ExtendResourceTypeConfigurationTUDo
  • Issue/1877-ExtendResourceTypeConfigurationNRWFHs
  • Issue/1910-MigrationtoNET6.0
  • Issue/1912-uriMadness
  • Issue/1938-internalHandling
  • Issue/1940ResouceKeysForNRWAndTUDO
  • Issue/1951-quotaImplementation
  • Issue/1953-owlImports
  • Issue/2061-activateResourceTypeRdss3nrw
  • Issue/2072-wormResourceType
  • Issue/2102-gitLabResTypeRCV
  • Issue/2122-retrieveWithoutFile
  • Issue/2162-fixFolderResponse
  • Issue/2162-fixFolderResponsev2
  • Issue/2173-numericalTypes
  • Issue/2195-modifiedDate
  • Issue/2287-guestRole
  • Issue/2309-docs
  • Issue/2349-gitlabHttps
  • Issue/2462-removeTraces
  • Issue/2583-treeBug
  • Product/1100-fdsS3
  • Product/1154-resourceTypeDefinition
  • Product/1188-LoggingExtended
  • Product/1188-logginExtended
  • Product/1287-dotnet5Sharepoint
  • Product/1472-exposingUrls
  • Product/1552-correctFolders
  • Product/1555-readOnlyResources
  • Product/1629-onboardingOtherUniversities
  • Product/938-docuTreeApi
  • Sprint/2020-20
  • Sprint/2020-21
  • Sprint/2020-22
  • Sprint/2021-01
  • Sprint/2021-03
  • Sprint/2021-05
  • Sprint/2021-08
  • Sprint/2021-09
  • Sprint/2021-10
  • Sprint/2021-11
  • Sprint/2021-13
  • Sprint/2021-15
  • Sprint/2021-16
  • Sprint/2021-23
  • Sprint/2022-01
  • Test/xxxx-enablingGitLab
  • Topic/1114-docuTreeApi
  • Topic/1159-rtdApi
  • Topic/1221-LogginExtendedNew
  • Topic/1221-loggingExtended
  • Topic/1292-FdsS3
  • Topic/1335-dotnet5Apis
  • Topic/1527-exposingUrls
  • Topic/1575-CheckArchivingStatus
  • Topic/1658-correctFolders
  • Topic/1673-DisplayFoldersMetadata
  • Topic/1711-extendResourceTypeConfiguration
  • dev
  • gitkeep
  • master
  • product/1472-exposingUrls
  • v2.8.14-Hotfix2365
  • v1.1.0
  • v1.1.1
  • v1.1.2
  • v1.1.3
  • v1.2.0
  • v1.2.1
  • v2.0.0
  • v2.0.1
  • v2.1.0
  • v2.1.1
  • v2.10.0
  • v2.10.1
  • v2.10.2
  • v2.10.3
  • v2.11.0
  • v2.11.1
  • v2.11.2
  • v2.11.3
  • v2.11.4
  • v2.11.5
  • v2.2.0
  • v2.2.1
  • v2.2.2
  • v2.3.0
  • v2.3.1
  • v2.3.2
  • v2.3.3
  • v2.3.4
  • v2.4.0
  • v2.4.1
  • v2.4.2
  • v2.4.3
  • v2.4.4
  • v2.5.0
  • v2.5.1
  • v2.5.2
  • v2.5.3
  • v2.6.0
  • v2.6.1
  • v2.6.2
  • v2.6.3
  • v2.6.4
  • v2.7.0
  • v2.8.0
  • v2.8.1
  • v2.8.10
  • v2.8.11
  • v2.8.12
  • v2.8.13
  • v2.8.14
  • v2.8.15
  • v2.8.16
  • v2.8.2
  • v2.8.3
  • v2.8.4
  • v2.8.5
  • v2.8.6
  • v2.8.7
  • v2.8.8
  • v2.8.9
  • v2.9.0
  • v2.9.1
  • v2.9.2
  • v2.9.3
  • v2.9.4
159 results

Target

Select target project
  • coscine/backend/apis/treeapi
1 result
Select Git revision
  • Fix/xxxx-activateGitlab
  • Fix/xxxx-resourceVisibility
  • Hotfix/0071-fixResourceCreate
  • Hotfix/1259-pathParameterFix
  • Hotfix/1260-fixUrl
  • Hotfix/1357-ymlFile
  • Hotfix/1370-swaggerDescription
  • Hotfix/1584-fixResourceLoader
  • Hotfix/1616-repairLinkedResources
  • Hotfix/1634-limitConsulCalls
  • Hotfix/1668-versionResourceConfigDepVersion
  • Hotfix/1681-fixLargeFileSizeQuery
  • Hotfix/1805-listingBreaks
  • Hotfix/2087-efNet6
  • Hotfix/2104-failedUpload
  • Hotfix/2141-fileUploadErrors
  • Hotfix/2233-fixMe
  • Hotfix/2254-fixContentLenghtCalculation
  • Hotfix/2296-selectedValuesNotReturned
  • Hotfix/2307-noLinkedTimeout
  • Hotfix/2313-fixModifiedDate
  • Hotfix/2365-targetClassWorks
  • Hotfix/2371-fixGitLabinRCV
  • Hotfix/2384-guestsAndLinked
  • Hotfix/2452-linkedDeletion
  • Hotfix/2459-EncodingPath
  • Hotfix/2504-formGen
  • Hotfix/64-releaseUDE
  • Issue/1741-semanticSearchActions
  • Issue/1792-newMetadataStructure
  • Issue/1804-fixedValueFix
  • Issue/1866-ExtendResourceTypeConfigurationTUDo
  • Issue/1877-ExtendResourceTypeConfigurationNRWFHs
  • Issue/1910-MigrationtoNET6.0
  • Issue/1912-uriMadness
  • Issue/1938-internalHandling
  • Issue/1940ResouceKeysForNRWAndTUDO
  • Issue/1951-quotaImplementation
  • Issue/1953-owlImports
  • Issue/2061-activateResourceTypeRdss3nrw
  • Issue/2072-wormResourceType
  • Issue/2102-gitLabResTypeRCV
  • Issue/2122-retrieveWithoutFile
  • Issue/2162-fixFolderResponse
  • Issue/2162-fixFolderResponsev2
  • Issue/2173-numericalTypes
  • Issue/2195-modifiedDate
  • Issue/2287-guestRole
  • Issue/2309-docs
  • Issue/2349-gitlabHttps
  • Issue/2462-removeTraces
  • Issue/2583-treeBug
  • Product/1100-fdsS3
  • Product/1154-resourceTypeDefinition
  • Product/1188-LoggingExtended
  • Product/1188-logginExtended
  • Product/1287-dotnet5Sharepoint
  • Product/1472-exposingUrls
  • Product/1552-correctFolders
  • Product/1555-readOnlyResources
  • Product/1629-onboardingOtherUniversities
  • Product/938-docuTreeApi
  • Sprint/2020-20
  • Sprint/2020-21
  • Sprint/2020-22
  • Sprint/2021-01
  • Sprint/2021-03
  • Sprint/2021-05
  • Sprint/2021-08
  • Sprint/2021-09
  • Sprint/2021-10
  • Sprint/2021-11
  • Sprint/2021-13
  • Sprint/2021-15
  • Sprint/2021-16
  • Sprint/2021-23
  • Sprint/2022-01
  • Test/xxxx-enablingGitLab
  • Topic/1114-docuTreeApi
  • Topic/1159-rtdApi
  • Topic/1221-LogginExtendedNew
  • Topic/1221-loggingExtended
  • Topic/1292-FdsS3
  • Topic/1335-dotnet5Apis
  • Topic/1527-exposingUrls
  • Topic/1575-CheckArchivingStatus
  • Topic/1658-correctFolders
  • Topic/1673-DisplayFoldersMetadata
  • Topic/1711-extendResourceTypeConfiguration
  • dev
  • gitkeep
  • master
  • product/1472-exposingUrls
  • v2.8.14-Hotfix2365
  • v1.1.0
  • v1.1.1
  • v1.1.2
  • v1.1.3
  • v1.2.0
  • v1.2.1
  • v2.0.0
  • v2.0.1
  • v2.1.0
  • v2.1.1
  • v2.10.0
  • v2.10.1
  • v2.10.2
  • v2.10.3
  • v2.11.0
  • v2.11.1
  • v2.11.2
  • v2.11.3
  • v2.11.4
  • v2.11.5
  • v2.2.0
  • v2.2.1
  • v2.2.2
  • v2.3.0
  • v2.3.1
  • v2.3.2
  • v2.3.3
  • v2.3.4
  • v2.4.0
  • v2.4.1
  • v2.4.2
  • v2.4.3
  • v2.4.4
  • v2.5.0
  • v2.5.1
  • v2.5.2
  • v2.5.3
  • v2.6.0
  • v2.6.1
  • v2.6.2
  • v2.6.3
  • v2.6.4
  • v2.7.0
  • v2.8.0
  • v2.8.1
  • v2.8.10
  • v2.8.11
  • v2.8.12
  • v2.8.13
  • v2.8.14
  • v2.8.15
  • v2.8.16
  • v2.8.2
  • v2.8.3
  • v2.8.4
  • v2.8.5
  • v2.8.6
  • v2.8.7
  • v2.8.8
  • v2.8.9
  • v2.9.0
  • v2.9.1
  • v2.9.2
  • v2.9.3
  • v2.9.4
159 results
Show changes

Commits on Source 4

## Tree # Tree API
The TreeApi handles the retrieving or storing metadata to a certain path. The TreeApi handles the retrieving or storing metadata to a certain path.
Check out the [docs](https://coscine.rwth-aachen.de/coscine/api/Coscine.Api.Tree/swagger). Check out the [docs](https://coscine.rwth-aachen.de/coscine/api/Coscine.Api.Tree/swagger).
using Coscine.Api.Tree.Util;
using Coscine.ApiCommons; using Coscine.ApiCommons;
using Coscine.ApiCommons.Factories; using Coscine.ApiCommons.Factories;
using Coscine.Configuration; using Coscine.Configuration;
...@@ -36,6 +35,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -36,6 +35,7 @@ namespace Coscine.Api.Tree.Controllers
private readonly Authenticator _authenticator; private readonly Authenticator _authenticator;
private readonly ResourceModel _resourceModel; private readonly ResourceModel _resourceModel;
private readonly RdfStoreConnector _rdfStoreConnector; private readonly RdfStoreConnector _rdfStoreConnector;
private readonly CoscineLDPHelper _coscineLDPHelper;
private readonly ProjectRoleModel _projectRoleModel; private readonly ProjectRoleModel _projectRoleModel;
private readonly ProjectResourceModel _projectResourceModel; private readonly ProjectResourceModel _projectResourceModel;
private readonly CoscineLogger _coscineLogger; private readonly CoscineLogger _coscineLogger;
...@@ -64,22 +64,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -64,22 +64,7 @@ namespace Coscine.Api.Tree.Controllers
var path = rule[rule.IndexOf("/")..]; var path = rule[rule.IndexOf("/")..];
_blobApiLink = $"https://{host}{path}/blob/"; _blobApiLink = $"https://{host}{path}/blob/";
_prefix = _configuration.GetStringAndWait("coscine/global/epic/prefix"); _prefix = _configuration.GetStringAndWait("coscine/global/epic/prefix");
} _coscineLDPHelper = new CoscineLDPHelper(_rdfStoreConnector, _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)
{
if (!path.StartsWith("/"))
{
path = "/" + path;
}
return new CustomUri($"https://hdl.handle.net/{_prefix}/{resourceId}@path={Uri.EscapeDataString(path)}");
} }
/// <summary> /// <summary>
...@@ -159,10 +144,12 @@ namespace Coscine.Api.Tree.Controllers ...@@ -159,10 +144,12 @@ namespace Coscine.Api.Tree.Controllers
var resourceTypeInformation = resourceTypeDefinition.GetResourceTypeInformation().Result; var resourceTypeInformation = resourceTypeDefinition.GetResourceTypeInformation().Result;
var metadataInfos = new List<ResourceEntry>(fileInfos); var metadataInfos = new List<ResourceEntry>(fileInfos);
var metadataIds = _rdfStoreConnector.ListMetadata(resourceId);
// Add to metadata infos, if no "physical" file for it exists // Add to metadata infos, if no "physical" file for it exists
if (!metadataInfos.Any((metadataInfo) => metadataInfo.Key == path)) if (!metadataInfos.Any((metadataInfo) => metadataInfo.Key == path))
{ {
metadataInfos.Add(new ResourceEntry(path, true, 0, GenerateId(resourceId, path).AbsoluteUri, null, DateTime.Now, DateTime.Now)); metadataInfos.Add(new ResourceEntry(path, true, 0, _coscineLDPHelper.GetId(resourceId, path, true, false, "metadata", metadataIds).AbsoluteUri, null, DateTime.Now, DateTime.Now));
} }
var applicationProfileGraph = _rdfStoreConnector.GetGraph(resource.ApplicationProfile); var applicationProfileGraph = _rdfStoreConnector.GetGraph(resource.ApplicationProfile);
...@@ -173,7 +160,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -173,7 +160,7 @@ namespace Coscine.Api.Tree.Controllers
int metadataCount = 0; int metadataCount = 0;
foreach (var info in metadataInfos) foreach (var info in metadataInfos)
{ {
var id = GenerateId(resourceId, info.Key); var id = _coscineLDPHelper.GetId(resourceId, info.Key, true, false, "metadata", metadataIds);
if (_rdfStoreConnector.HasGraph(id.AbsoluteUri)) if (_rdfStoreConnector.HasGraph(id.AbsoluteUri))
{ {
var graph = _rdfStoreConnector.GetGraph(id); var graph = _rdfStoreConnector.GetGraph(id);
...@@ -297,9 +284,9 @@ namespace Coscine.Api.Tree.Controllers ...@@ -297,9 +284,9 @@ namespace Coscine.Api.Tree.Controllers
/// <returns>If OK status code 204, otherwise status code 400 or 401</returns> /// <returns>If OK status code 204, otherwise status code 400 or 401</returns>
[HttpPut("[controller]/{resourceId}/{*path}")] [HttpPut("[controller]/{resourceId}/{*path}")]
[ApiExplorerSettings(IgnoreApi = true)] [ApiExplorerSettings(IgnoreApi = true)]
public IActionResult StoreMetadataForFileWithPath(string resourceId, string path) public async Task<IActionResult> StoreMetadataForFileWithPath(string resourceId, string path)
{ {
return StoreMetadataForFile(resourceId, path); return await StoreMetadataForFile(resourceId, path);
} }
/// <summary> /// <summary>
...@@ -310,7 +297,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -310,7 +297,7 @@ namespace Coscine.Api.Tree.Controllers
/// <param name="mimeType">Requested MimeType of the metadata</param> /// <param name="mimeType">Requested MimeType of the metadata</param>
/// <returns>If OK status code 204, otherwise status code 400 or 401</returns> /// <returns>If OK status code 204, otherwise status code 400 or 401</returns>
[HttpPut("[controller]/{resourceId}/")] [HttpPut("[controller]/{resourceId}/")]
public IActionResult StoreMetadataForFileWithParameter(string resourceId, [FromQuery] string path = "", [FromQuery] string mimeType = "application/rdf+json") public async Task<IActionResult> StoreMetadataForFileWithParameter(string resourceId, [FromQuery] string path = "", [FromQuery] string mimeType = "application/rdf+json")
{ {
// Strip the first slash, to reuse the previous implementation. // Strip the first slash, to reuse the previous implementation.
if (path.StartsWith("/")) if (path.StartsWith("/"))
...@@ -318,7 +305,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -318,7 +305,7 @@ namespace Coscine.Api.Tree.Controllers
path = path[1..]; path = path[1..];
} }
return StoreMetadataForFile(resourceId, path, mimeType); return await StoreMetadataForFile(resourceId, path, mimeType);
} }
/// <summary> /// <summary>
...@@ -328,7 +315,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -328,7 +315,7 @@ namespace Coscine.Api.Tree.Controllers
/// <param name="path">Path to the file</param> /// <param name="path">Path to the file</param>
/// <param name="mimeType">Requested MimeType of the metadata</param> /// <param name="mimeType">Requested MimeType of the metadata</param>
/// <returns>If OK status code 204, otherwise status code 400 or 401</returns> /// <returns>If OK status code 204, otherwise status code 400 or 401</returns>
public IActionResult StoreMetadataForFile(string resourceId, string path, string mimeType = "application/rdf+json") public async Task<IActionResult> StoreMetadataForFile(string resourceId, string path, string mimeType = "application/rdf+json")
{ {
path = $"/{path}"; path = $"/{path}";
if (path.Contains("%2F") || path.Contains("%2f")) if (path.Contains("%2F") || path.Contains("%2f"))
...@@ -339,7 +326,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -339,7 +326,7 @@ namespace Coscine.Api.Tree.Controllers
// Ducktape solution for supporting multiple mimetypes // Ducktape solution for supporting multiple mimetypes
var metadataObject = ObjectFactory<JToken>.DeserializeFromStream(Request.Body); var metadataObject = ObjectFactory<JToken>.DeserializeFromStream(Request.Body);
var graphNameUri = GenerateId(resourceId, path); var graphNameUri = _coscineLDPHelper.GetId(resourceId, path, false, true);
JObject json; JObject json;
...@@ -443,38 +430,15 @@ namespace Coscine.Api.Tree.Controllers ...@@ -443,38 +430,15 @@ namespace Coscine.Api.Tree.Controllers
return BadRequest("Data has the wrong format!"); return BadRequest("Data has the wrong format!");
} }
// store the data
if (_rdfStoreConnector.HasGraph(graphNameUri))
{
_rdfStoreConnector.ClearGraph(graphNameUri);
if (CoscineLoggerConfiguration.IsLogLevelActivated(LogType.Analytics))
{
LogAnalyticsUpdateMd(_projectResourceModel.GetProjectForResource(resource.Id).Value, resource.Id, path, user, GetMetadataCompleteness(graph.Triples.Count, resource));
}
}
else
{
try
{
_rdfStoreConnector.CreateNamedGraph(graphNameUri);
}
#pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception.
catch (Exception)
#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception.
{
// Graph creation failed because it has been created before, skip this for now
}
if (CoscineLoggerConfiguration.IsLogLevelActivated(LogType.Analytics)) if (CoscineLoggerConfiguration.IsLogLevelActivated(LogType.Analytics))
{ {
LogAnalyticsUploadMd(_projectResourceModel.GetProjectForResource(resource.Id).Value, resource.Id, path, user, GetMetadataCompleteness(graph.Triples.Count, resource)); LogAnalyticsUploadMd(_projectResourceModel.GetProjectForResource(resource.Id).Value, resource.Id, path, user, GetMetadataCompleteness(graph.Triples.Count, resource));
} }
}
// BaseUri must be set for the sparql query // BaseUri must be set for the sparql query
graph.BaseUri = graphNameUri; graph.BaseUri = graphNameUri;
_rdfStoreConnector.AddGraph(graph);
await _rdfStoreConnector.AddMetadataAsync(graph);
return NoContent(); return NoContent();
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<AssemblyName>Coscine.Api.Tree</AssemblyName> <AssemblyName>Coscine.Api.Tree</AssemblyName>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Version>2.9.4</Version> <Version>2.10.0</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<Authors>RWTH Aachen University</Authors> <Authors>RWTH Aachen University</Authors>
......
using System;
namespace Coscine.Api.Tree.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;
}
}
}