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

Merge branch 'Hotfix/1259-pathParameterFix' into 'Sprint/2021-23'

Fix: added query parameter call (coscine/issues#1259)

See merge request !51
parents 98447ddc 61ed84ba
No related branches found
No related tags found
2 merge requests!52Sprint/2021 23,!51Fix: added query parameter call (coscine/issues#1259)
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.156
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tree", "Tree\Tree.csproj", "{AC8882D4-3F0C-4BBF-83CE-22A5B05ED3FB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tree", "Tree\Tree.csproj", "{AC8882D4-3F0C-4BBF-83CE-22A5B05ED3FB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
......@@ -11,6 +11,7 @@ using Coscine.ResourceTypeBase;
using Coscine.WaterbutlerHelper;
using Coscine.WaterbutlerHelper.ReturnObjects;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
......@@ -83,6 +84,36 @@ namespace Coscine.Api.Tree.Controllers
/// <param name="path">Path to the file</param>
/// <returns> JSON Object with the metadata if OK, otherwise status code 400 or 401 or 404</returns>
[HttpGet("[controller]/{resourceId}/{*path}")]
[ApiExplorerSettings(IgnoreApi = true)]
public async Task<IActionResult> GetMetadataWithPath(string resourceId, string path = "")
{
return await GetMetadata(resourceId, path);
}
/// <summary>
/// This method retrieves the metadata
/// </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 status code 400 or 401 or 404</returns>
[HttpGet("[controller]/{resourceId}/")]
public async Task<IActionResult> GetMetadataWithParameter(string resourceId, [System.Web.Http.FromUri] string path = "")
{
// Strip the first slash, to reuse the previous implementation.
if (path.StartsWith("/"))
{
path = path[1..];
}
return await GetMetadata(resourceId, path);
}
/// <summary>
/// This method retrieves the metadata
/// </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 status code 400 or 401 or 404</returns>
public async Task<IActionResult> GetMetadata(string resourceId, string path = "")
{
var rawPath = path;
......@@ -195,9 +226,9 @@ namespace Coscine.Api.Tree.Controllers
return Json(jObject);
}
catch (Exception e)
catch (Exception)
{
return BadRequest($"Error in communication with the resource");
return BadRequest("Error in communication with the resource");
}
}
......@@ -230,6 +261,36 @@ namespace Coscine.Api.Tree.Controllers
/// <param name="path">Path to the file</param>
/// <returns>If OK status code 204, otherwise status code 400 or 401</returns>
[HttpPut("[controller]/{resourceId}/{*path}")]
[ApiExplorerSettings(IgnoreApi = true)]
public IActionResult StoreMetadataForFileWithPath(string resourceId, string path)
{
return StoreMetadataForFile(resourceId, path);
}
/// <summary>
/// This method stores the metadata of the file
/// </summary>
/// <param name="resourceId">Id of the resource</param>
/// <param name="path">Path to the file</param>
/// <returns>If OK status code 204, otherwise status code 400 or 401</returns>
[HttpPut("[controller]/{resourceId}/")]
public IActionResult StoreMetadataForFileWithParameter(string resourceId, [System.Web.Http.FromUri] string path = "")
{
// Strip the first slash, to reuse the previous implementation.
if (path.StartsWith("/"))
{
path = path[1..];
}
return StoreMetadataForFile(resourceId, path);
}
/// <summary>
/// This method stores the metadata of the file
/// </summary>
/// <param name="resourceId">Id of the resource</param>
/// <param name="path">Path to the file</param>
/// <returns>If OK status code 204, otherwise status code 400 or 401</returns>
public IActionResult StoreMetadataForFile(string resourceId, string path)
{
path = $"/{path}";
......
......@@ -24,5 +24,6 @@
<PackageReference Include="Coscine.ResourceLoader" Version="2.*-*" />
<PackageReference Include="Coscine.ResourceTypeBase" Version="2.*-*" />
<PackageReference Include="Coscine.WaterbutlerHelper" Version="2.*-*" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.7" />
</ItemGroup>
</Project>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment