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

Merge branch 'Hotfix/0071-fixResourceCreate' into 'master'

Hotfix/0071 fix resource create

See merge request !50
parents 0007628f 715cdbaf
No related branches found
No related tags found
1 merge request!50Hotfix/0071 fix resource create
using Coscine.WaterbutlerHelper;
using Coscine.WaterbutlerHelper.ReturnObjects;
using Coscine.ApiCommons; using Coscine.ApiCommons;
using Coscine.ApiCommons.Factories; using Coscine.ApiCommons.Factories;
using Coscine.Configuration;
using Coscine.Database.DataModel; using Coscine.Database.DataModel;
using Coscine.Database.Models; 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.ResourceLoader;
using Coscine.ResourceTypeBase;
using Coscine.WaterbutlerHelper;
using Coscine.WaterbutlerHelper.ReturnObjects;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
...@@ -20,9 +23,6 @@ using System.Web; ...@@ -20,9 +23,6 @@ using System.Web;
using VDS.RDF; using VDS.RDF;
using VDS.RDF.Parsing; using VDS.RDF.Parsing;
using VDS.RDF.Writing; using VDS.RDF.Writing;
using Coscine.ResourceLoader;
using Coscine.Configuration;
using Coscine.ResourceTypeBase;
namespace Coscine.Api.Tree.Controllers namespace Coscine.Api.Tree.Controllers
{ {
...@@ -81,7 +81,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -81,7 +81,7 @@ namespace Coscine.Api.Tree.Controllers
/// </summary> /// </summary>
/// <param name="resourceId"> Id of a resource</param> /// <param name="resourceId"> Id of a resource</param>
/// <param name="path">Path to the file</param> /// <param name="path">Path to the file</param>
/// <returns> JSON Object with the metadata if ok, otherwise Statuscode 400 or 401 or 404</returns> /// <returns> JSON Object with the metadata if OK, otherwise status code 400 or 401 or 404</returns>
[HttpGet("[controller]/{resourceId}/{*path}")] [HttpGet("[controller]/{resourceId}/{*path}")]
public async Task<IActionResult> GetMetadata(string resourceId, string path = "") public async Task<IActionResult> GetMetadata(string resourceId, string path = "")
{ {
...@@ -118,7 +118,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -118,7 +118,7 @@ namespace Coscine.Api.Tree.Controllers
return BadRequest($"No provider for: \"{resource.Type.DisplayName}\"."); return BadRequest($"No provider for: \"{resource.Type.DisplayName}\".");
} }
var fileInfos = await resourceTypeDefinition.ListEntries(resourceId, path, resourceTypeOptions); var fileInfos = await resourceTypeDefinition.ListEntries(null, path, resourceTypeOptions);
var metadataInfos = new List<ResourceEntry>(fileInfos); var metadataInfos = new List<ResourceEntry>(fileInfos);
if (path.EndsWith("/")) if (path.EndsWith("/"))
...@@ -126,7 +126,6 @@ namespace Coscine.Api.Tree.Controllers ...@@ -126,7 +126,6 @@ namespace Coscine.Api.Tree.Controllers
metadataInfos.Insert(0, new ResourceEntry(path, false, 0, null, null, new DateTime(), new DateTime())); metadataInfos.Insert(0, new ResourceEntry(path, false, 0, null, null, new DateTime(), new DateTime()));
} }
var graphs = new List<JToken>(); var graphs = new List<JToken>();
int metadataCount = 0; int metadataCount = 0;
foreach (var info in metadataInfos) foreach (var info in metadataInfos)
...@@ -211,7 +210,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -211,7 +210,7 @@ namespace Coscine.Api.Tree.Controllers
{ {
var lastSlash = x.Key.LastIndexOf("/") + 1; var lastSlash = x.Key.LastIndexOf("/") + 1;
var name = x.Key[lastSlash..]; var name = x.Key[lastSlash..];
if (name == "") if (name?.Length == 0)
{ {
var tempPath = x.Key[..(lastSlash - 1)]; var tempPath = x.Key[..(lastSlash - 1)];
if (tempPath.Contains("/")) if (tempPath.Contains("/"))
...@@ -229,7 +228,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -229,7 +228,7 @@ namespace Coscine.Api.Tree.Controllers
/// </summary> /// </summary>
/// <param name="resourceId">Id of the resource</param> /// <param name="resourceId">Id of the resource</param>
/// <param name="path">Path to the file</param> /// <param name="path">Path to the file</param>
/// <returns>If ok Statuscode 204, otherwise Statuscode 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}")]
public IActionResult StoreMetadataForFile(string resourceId, string path) public IActionResult StoreMetadataForFile(string resourceId, string path)
{ {
...@@ -356,7 +355,6 @@ namespace Coscine.Api.Tree.Controllers ...@@ -356,7 +355,6 @@ namespace Coscine.Api.Tree.Controllers
_rdfStoreConnector.AddGraph(graph); _rdfStoreConnector.AddGraph(graph);
return NoContent(); return NoContent();
} }
/// <summary> /// <summary>
...@@ -365,7 +363,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -365,7 +363,7 @@ namespace Coscine.Api.Tree.Controllers
/// <param name="resourceId">Id of the resource</param> /// <param name="resourceId">Id of the resource</param>
/// <param name="path">Path to the file</param> /// <param name="path">Path to the file</param>
/// <param name="resource">Resource</param> /// <param name="resource">Resource</param>
/// <returns>null, otherwise Statuscode 400 or 404 </returns> /// <returns>null, otherwise status code 400 or 404 </returns>
private IActionResult CheckResourceIdAndPath(string resourceId, string path, out Resource resource) private IActionResult CheckResourceIdAndPath(string resourceId, string path, out Resource resource)
{ {
resource = null; resource = null;
...@@ -383,7 +381,7 @@ namespace Coscine.Api.Tree.Controllers ...@@ -383,7 +381,7 @@ namespace Coscine.Api.Tree.Controllers
if (!Guid.TryParse(resourceId, out Guid resourceGuid)) if (!Guid.TryParse(resourceId, out Guid resourceGuid))
{ {
return BadRequest($"{resourceId} is not a guid."); return BadRequest($"{resourceId} is not a GUID.");
} }
try try
......
using Coscine.WaterbutlerHelper.Services; using Coscine.ApiCommons;
using Coscine.ApiCommons; using Coscine.WaterbutlerHelper.Services;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using System; using System;
...@@ -15,8 +15,8 @@ namespace Coscine.Api.Tree ...@@ -15,8 +15,8 @@ namespace Coscine.Api.Tree
/// </summary> /// </summary>
public Startup() public Startup()
{ {
} }
/// <summary> /// <summary>
/// Configures custom service extension /// Configures custom service extension
/// </summary> /// </summary>
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
<PackageReference Include="Coscine.Logging" Version="2.*-*" /> <PackageReference Include="Coscine.Logging" Version="2.*-*" />
<PackageReference Include="Coscine.Metadata" Version="2.*-*" /> <PackageReference Include="Coscine.Metadata" Version="2.*-*" />
<PackageReference Include="Coscine.ResourceLoader" Version="2.*-*" /> <PackageReference Include="Coscine.ResourceLoader" Version="2.*-*" />
<PackageReference Include="Coscine.ResourceTypeBase" Version="2.*-*" />
<PackageReference Include="Coscine.WaterbutlerHelper" Version="2.*-*" /> <PackageReference Include="Coscine.WaterbutlerHelper" Version="2.*-*" />
</ItemGroup> </ItemGroup>
</Project> </Project>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment