diff --git a/src/Tree/Controllers/TreeController.cs b/src/Tree/Controllers/TreeController.cs index 23dc8470652f880099fda4e1f6edfbb51a2544b3..3c4ee7a4a295f48a8d00aea14532b78872038e94 100644 --- a/src/Tree/Controllers/TreeController.cs +++ b/src/Tree/Controllers/TreeController.cs @@ -1,12 +1,15 @@ -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 = "") { @@ -117,8 +117,8 @@ 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) { @@ -257,7 +256,7 @@ namespace Coscine.Api.Tree.Controllers if (resource.Archived == "1") { - return BadRequest("The resource is readonly!"); + return BadRequest("The resource is read only!"); } if (resource.ApplicationProfile[^1] != '/') @@ -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 @@ -472,4 +470,4 @@ namespace Coscine.Api.Tree.Controllers return $"{present}/{total}"; } } -} +} \ No newline at end of file diff --git a/src/Tree/Program.cs b/src/Tree/Program.cs index 9f4c22ca9f7390cd4d5fda216a9ffeece503f083..0231458183aefb962a3d8f30debcdf54d16847d6 100644 --- a/src/Tree/Program.cs +++ b/src/Tree/Program.cs @@ -17,4 +17,4 @@ namespace Coscine.Api.Tree InitializeWebService<Startup>(); } } -} +} \ No newline at end of file diff --git a/src/Tree/Startup.cs b/src/Tree/Startup.cs index 38f4352c2b3044d7513c733bb6beede7fc0bb713..0f5f43fdb34d5884e923d0aa483cbc28b73466e5 100644 --- a/src/Tree/Startup.cs +++ b/src/Tree/Startup.cs @@ -1,5 +1,5 @@ -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> @@ -32,4 +32,4 @@ namespace Coscine.Api.Tree }); } } -} +} \ No newline at end of file diff --git a/src/Tree/Tree.csproj b/src/Tree/Tree.csproj index 2acee8e02a538c0449130b5ec0aa834f5be93f72..256a212193888dc7def92cd0b70abeddc7bb7a2f 100644 --- a/src/Tree/Tree.csproj +++ b/src/Tree/Tree.csproj @@ -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.ResourceTypeBase" Version="2.*-*" /> <PackageReference Include="Coscine.WaterbutlerHelper" Version="2.*-*" /> </ItemGroup> -</Project> \ No newline at end of file +</Project>