Skip to content
Snippets Groups Projects
Commit fdbb5c05 authored by L. Ellenbeck's avatar L. Ellenbeck
Browse files

Fix: Ude resources (rpdm/issues#71)

parent 0007628f
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.Factories;
using Coscine.Configuration;
using Coscine.Database.DataModel;
using Coscine.Database.Models;
using Coscine.Database.Util;
using Coscine.Logging;
using Coscine.Metadata;
using Coscine.ResourceLoader;
using Coscine.ResourceTypeBase;
using Coscine.WaterbutlerHelper;
using Coscine.WaterbutlerHelper.ReturnObjects;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
......@@ -20,9 +23,6 @@ using System.Web;
using VDS.RDF;
using VDS.RDF.Parsing;
using VDS.RDF.Writing;
using Coscine.ResourceLoader;
using Coscine.Configuration;
using Coscine.ResourceTypeBase;
namespace Coscine.Api.Tree.Controllers
{
......@@ -81,7 +81,7 @@ namespace Coscine.Api.Tree.Controllers
/// </summary>
/// <param name="resourceId"> Id of a resource</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}")]
public async Task<IActionResult> GetMetadata(string resourceId, string path = "")
{
......@@ -118,7 +118,7 @@ namespace Coscine.Api.Tree.Controllers
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);
if (path.EndsWith("/"))
......@@ -126,7 +126,6 @@ namespace Coscine.Api.Tree.Controllers
metadataInfos.Insert(0, new ResourceEntry(path, false, 0, null, null, new DateTime(), new DateTime()));
}
var graphs = new List<JToken>();
int metadataCount = 0;
foreach (var info in metadataInfos)
......@@ -211,7 +210,7 @@ namespace Coscine.Api.Tree.Controllers
{
var lastSlash = x.Key.LastIndexOf("/") + 1;
var name = x.Key[lastSlash..];
if (name == "")
if (name?.Length == 0)
{
var tempPath = x.Key[..(lastSlash - 1)];
if (tempPath.Contains("/"))
......@@ -229,7 +228,7 @@ namespace Coscine.Api.Tree.Controllers
/// </summary>
/// <param name="resourceId">Id of the resource</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}")]
public IActionResult StoreMetadataForFile(string resourceId, string path)
{
......@@ -356,7 +355,6 @@ namespace Coscine.Api.Tree.Controllers
_rdfStoreConnector.AddGraph(graph);
return NoContent();
}
/// <summary>
......@@ -365,7 +363,7 @@ namespace Coscine.Api.Tree.Controllers
/// <param name="resourceId">Id of the resource</param>
/// <param name="path">Path to the file</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)
{
resource = null;
......@@ -383,7 +381,7 @@ namespace Coscine.Api.Tree.Controllers
if (!Guid.TryParse(resourceId, out Guid resourceGuid))
{
return BadRequest($"{resourceId} is not a guid.");
return BadRequest($"{resourceId} is not a GUID.");
}
try
......
using Coscine.WaterbutlerHelper.Services;
using Coscine.ApiCommons;
using Coscine.ApiCommons;
using Coscine.WaterbutlerHelper.Services;
using Microsoft.Extensions.DependencyInjection;
using System;
......@@ -15,8 +15,8 @@ namespace Coscine.Api.Tree
/// </summary>
public Startup()
{
}
/// <summary>
/// Configures custom service extension
/// </summary>
......
......@@ -22,6 +22,7 @@
<PackageReference Include="Coscine.Logging" Version="2.*-*" />
<PackageReference Include="Coscine.Metadata" Version="2.*-*" />
<PackageReference Include="Coscine.ResourceLoader" Version="2.*-*" />
<PackageReference Include="Coscine.WaterbutlerHelper" Version="2.*-*" />
<PackageReference Include="Coscine.ResourceTypeBase" Version="2.3.1-gitkeep0001" />
<PackageReference Include="Coscine.WaterbutlerHelper" Version="2.1.2-beta0003" />
</ItemGroup>
</Project>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment