Commit 995ec319 authored by Marcel Nellesen's avatar Marcel Nellesen
Browse files

Merge branch 'Sprint/2021-01' into 'master'

Sprint/2021 01

See merge request !14
parents b0324fbd eecbf4e7
......@@ -21,7 +21,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Coscine.Configuration" publicKeyToken="ce3d7a32d7dc1e5a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.0.0" newVersion="1.5.0.0" />
<bindingRedirect oldVersion="0.0.0.0-1.6.0.0" newVersion="1.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
......@@ -29,15 +29,15 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Logging" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.7.1.0" newVersion="6.7.1.0" />
<bindingRedirect oldVersion="0.0.0.0-6.8.0.0" newVersion="6.8.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Tokens" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.7.1.0" newVersion="6.7.1.0" />
<bindingRedirect oldVersion="0.0.0.0-6.8.0.0" newVersion="6.8.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.7.1.0" newVersion="6.7.1.0" />
<bindingRedirect oldVersion="0.0.0.0-6.8.0.0" newVersion="6.8.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
......@@ -57,7 +57,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.5.0" newVersion="3.1.5.0" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging" publicKeyToken="adb9793829ddae60" culture="neutral" />
......@@ -165,7 +165,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Coscine.Database" publicKeyToken="767d77427707b70a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.27.0.0" newVersion="1.27.0.0" />
<bindingRedirect oldVersion="0.0.0.0-1.28.0.0" newVersion="1.28.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Coscine.ApiCommons" publicKeyToken="af4c1345df96546b" culture="neutral" />
......@@ -197,11 +197,19 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="linq2db" publicKeyToken="e41013125f9e410a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.1.0" newVersion="3.1.1.0" />
<bindingRedirect oldVersion="0.0.0.0-3.2.3.0" newVersion="3.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Coscine.Database.T4" publicKeyToken="84b4c404a0696261" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.27.0.0" newVersion="1.27.0.0" />
<bindingRedirect oldVersion="0.0.0.0-1.28.0.0" newVersion="1.28.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="LinqKit" publicKeyToken="bc217f8844052a91" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.1.22.0" newVersion="1.1.22.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.11.29.0" newVersion="1.11.29.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
......
This diff is collapsed.
......@@ -4,6 +4,7 @@ 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.Services;
......@@ -14,6 +15,7 @@ using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
......@@ -34,6 +36,8 @@ namespace Coscine.Api.Blob.Controllers
private readonly ProjectRoleModel _projectRoleModel;
private readonly CoscineLogger _coscineLogger;
private readonly AnalyticsLogObject _analyticsLogObject;
private readonly RdfStoreConnector _rdfStoreConnector;
private readonly string _prefix;
/// <summary>
/// Blob controller constructor
......@@ -47,10 +51,24 @@ namespace Coscine.Api.Blob.Controllers
_resourceModel = new ResourceModel();
_projectResourceModel = new ProjectResourceModel();
_projectRoleModel = new ProjectRoleModel();
_rdfStoreConnector = new RdfStoreConnector(_configuration.GetStringAndWait("coscine/local/virtuoso/additional/url"));
_coscineLogger = new CoscineLogger(logger);
_analyticsLogObject = new AnalyticsLogObject();
_prefix = _configuration.GetStringAndWait("coscine/global/epic/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)
{
return new Uri($"https://hdl.handle.net/{_prefix}/{resourceId}@path={Uri.EscapeDataString(path)}");
}
/// <summary>
/// This method returns the amount of allocated space for the given resource
/// </summary>
......@@ -170,7 +188,7 @@ namespace Coscine.Api.Blob.Controllers
/// </summary>
/// <param name="resourceId">Id of the resource </param>
/// <param name="path">Path to the file</param>
/// <returns>Statuscode 204 if file is uploaded otherwise Statuscode 400, 401 or 404</returns>
/// <returns>Statuscode 204 if file is uploaded otherwise Statuscode 400 or 403</returns>
[HttpPut("[controller]/{resourceId}/{*path}")]
[DisableRequestSizeLimit]
public async Task<IActionResult> UploadFile(string resourceId, string path)
......@@ -191,7 +209,15 @@ namespace Coscine.Api.Blob.Controllers
if (user == null || !_resourceModel.HasAccess(user, resource, UserRoles.Owner, UserRoles.Member))
{
return Forbid("User does not have permission to the resource.");
return StatusCode((int)HttpStatusCode.Forbidden,
"User does not have permission to the resource.");
}
var id = GenerateId(resourceId, path);
if (!_rdfStoreConnector.HasGraph(id.AbsoluteUri))
{
return StatusCode((int)HttpStatusCode.Forbidden,
"No metadataset has been added for this file.");
}
try
......@@ -221,6 +247,7 @@ namespace Coscine.Api.Blob.Controllers
return BadRequest($"Error in communication with the resource");
}
}
/// <summary>
/// This method deletes a given file
/// </summary>
......@@ -267,6 +294,7 @@ namespace Coscine.Api.Blob.Controllers
return BadRequest($"Error in communication with the resource");
}
}
/// <summary>
/// This method checks if the resource is valid
/// </summary>
......@@ -353,6 +381,7 @@ namespace Coscine.Api.Blob.Controllers
// All good
return null;
}
/// <summary>
/// Writes an analytics log entry
/// </summary>
......
......@@ -2,21 +2,25 @@
<packages>
<package id="AWSSDK.Core" version="3.5.1.23" targetFramework="net461" />
<package id="AWSSDK.S3" version="3.5.3.1" targetFramework="net461" />
<package id="Consul" version="0.7.2.6" targetFramework="net461" />
<package id="Coscine.ApiCommons" version="1.11.0" targetFramework="net461" />
<package id="Coscine.Configuration" version="1.5.0" targetFramework="net461" />
<package id="Coscine.Database" version="1.27.0" targetFramework="net461" />
<package id="Coscine.JwtHandler" version="1.2.0" targetFramework="net461" />
<package id="Coscine.Logging" version="1.2.0" targetFramework="net461" />
<package id="Coscine.ResourceConfiguration" version="1.3.0" targetFramework="net461" />
<package id="Coscine.ResourceLoader" version="1.2.0" targetFramework="net461" />
<package id="Coscine.ResourceTypeBase" version="1.4.0" targetFramework="net461" />
<package id="Coscine.WaterbutlerHelper" version="1.2.1" targetFramework="net461" />
<package id="Consul" version="1.6.1.1" targetFramework="net461" />
<package id="Coscine.ApiCommons" version="1.12.0" targetFramework="net461" />
<package id="Coscine.Configuration" version="1.6.0" targetFramework="net461" />
<package id="Coscine.Database" version="1.28.0" targetFramework="net461" />
<package id="Coscine.JwtHandler" version="1.3.0" targetFramework="net461" />
<package id="Coscine.Logging" version="1.3.0" targetFramework="net461" />
<package id="Coscine.Metadata" version="1.6.0" targetFramework="net461" />
<package id="Coscine.ResourceConfiguration" version="1.4.0" targetFramework="net461" />
<package id="Coscine.ResourceLoader" version="1.3.0" targetFramework="net461" />
<package id="Coscine.ResourceTypeBase" version="1.5.0" targetFramework="net461" />
<package id="Coscine.WaterbutlerHelper" version="1.3.0" targetFramework="net461" />
<package id="dotNetRDF" version="2.6.1" targetFramework="net461" />
<package id="dotNetRDF.Data.Virtuoso" version="2.6.1" targetFramework="net461" />
<package id="EntityFramework" version="6.4.4" targetFramework="net461" />
<package id="linq2db" version="3.1.1" targetFramework="net461" />
<package id="linq2db.SqlServer" version="2.6.4" targetFramework="net461" />
<package id="linq2db.t4models" version="2.6.4" targetFramework="net461" />
<package id="LinqKit" version="1.1.17" targetFramework="net461" />
<package id="HtmlAgilityPack" version="1.11.29" targetFramework="net461" />
<package id="linq2db" version="3.2.3" targetFramework="net461" />
<package id="linq2db.SqlServer" version="3.2.3" targetFramework="net461" />
<package id="linq2db.t4models" version="3.2.3" targetFramework="net461" />
<package id="LinqKit" version="1.1.22" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Antiforgery" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Authentication" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Authentication.Abstractions" version="2.2.0" targetFramework="net461" />
......@@ -31,7 +35,7 @@
<package id="Microsoft.AspNetCore.DataProtection.Abstractions" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Diagnostics" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Diagnostics.Abstractions" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Hosting" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Hosting" version="2.2.7" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Hosting.Abstractions" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Hosting.Server.Abstractions" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Html.Abstractions" version="2.2.0" targetFramework="net461" />
......@@ -84,7 +88,7 @@
<package id="Microsoft.Extensions.Configuration" version="3.1.5" targetFramework="net461" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="3.1.5" targetFramework="net461" />
<package id="Microsoft.Extensions.Configuration.Binder" version="3.1.5" targetFramework="net461" />
<package id="Microsoft.Extensions.Configuration.EnvironmentVariables" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.Extensions.Configuration.EnvironmentVariables" version="2.2.4" targetFramework="net461" />
<package id="Microsoft.Extensions.Configuration.FileExtensions" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.Extensions.DependencyInjection" version="3.1.5" targetFramework="net461" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="3.1.5" targetFramework="net461" />
......@@ -99,33 +103,35 @@
<package id="Microsoft.Extensions.Localization" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.Extensions.Localization.Abstractions" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.Extensions.Logging" version="3.1.5" targetFramework="net461" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="3.1.5" targetFramework="net461" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="5.0.0" targetFramework="net461" />
<package id="Microsoft.Extensions.ObjectPool" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.Extensions.Options" version="3.1.5" targetFramework="net461" />
<package id="Microsoft.Extensions.Primitives" version="3.1.5" targetFramework="net461" />
<package id="Microsoft.Extensions.WebEncoders" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="6.7.1" targetFramework="net461" />
<package id="Microsoft.IdentityModel.Logging" version="6.7.1" targetFramework="net461" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="6.8.0" targetFramework="net461" />
<package id="Microsoft.IdentityModel.Logging" version="6.8.0" targetFramework="net461" />
<package id="Microsoft.IdentityModel.Protocols" version="5.3.0" targetFramework="net461" />
<package id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="5.3.0" targetFramework="net461" />
<package id="Microsoft.IdentityModel.Tokens" version="6.7.1" targetFramework="net461" />
<package id="Microsoft.IdentityModel.Tokens" version="6.8.0" targetFramework="net461" />
<package id="Microsoft.Net.Http.Headers" version="2.2.0" targetFramework="net461" />
<package id="Microsoft.Win32.Registry" version="4.5.0" targetFramework="net461" />
<package id="Namotion.Reflection" version="1.0.11" targetFramework="net461" />
<package id="Namotion.Reflection" version="1.0.15" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
<package id="Newtonsoft.Json.Bson" version="1.0.2" targetFramework="net461" />
<package id="NJsonSchema" version="10.1.23" targetFramework="net461" />
<package id="NLog" version="4.6.8" targetFramework="net461" />
<package id="NLog.Config" version="4.6.8" targetFramework="net461" />
<package id="NLog.Extensions.Logging" version="1.6.1" targetFramework="net461" />
<package id="NLog.Schema" version="4.6.8" targetFramework="net461" />
<package id="NLog.Web.AspNetCore" version="4.9.0" targetFramework="net461" />
<package id="NSwag.Annotations" version="13.6.2" targetFramework="net461" />
<package id="NSwag.AspNetCore" version="13.6.2" targetFramework="net461" />
<package id="NSwag.Core" version="13.6.2" targetFramework="net461" />
<package id="NSwag.Generation" version="13.6.2" targetFramework="net461" />
<package id="NSwag.Generation.AspNetCore" version="13.6.2" targetFramework="net461" />
<package id="NJsonSchema" version="10.3.3" targetFramework="net461" />
<package id="NLog" version="4.7.7" targetFramework="net461" />
<package id="NLog.Config" version="4.7.7" targetFramework="net461" />
<package id="NLog.Extensions.Logging" version="1.7.0" targetFramework="net461" />
<package id="NLog.Schema" version="4.7.7" targetFramework="net461" />
<package id="NLog.Web.AspNetCore" version="4.10.0" targetFramework="net461" />
<package id="NSwag.Annotations" version="13.10.1" targetFramework="net461" />
<package id="NSwag.AspNetCore" version="13.10.1" targetFramework="net461" />
<package id="NSwag.Core" version="13.10.1" targetFramework="net461" />
<package id="NSwag.Generation" version="13.10.1" targetFramework="net461" />
<package id="NSwag.Generation.AspNetCore" version="13.10.1" targetFramework="net461" />
<package id="NUnit" version="3.12.0" targetFramework="net461" />
<package id="OpenLink.Data.Virtuoso" version="7.20.3214.1" targetFramework="net461" />
<package id="SQLitePCLRaw.lib.e_sqlite3" version="2.0.4" targetFramework="net461" />
<package id="System.AppContext" version="4.3.0" targetFramework="net461" />
<package id="System.Buffers" version="4.5.0" targetFramework="net461" />
<package id="System.Collections" version="4.3.0" targetFramework="net461" />
......@@ -135,7 +141,7 @@
<package id="System.Diagnostics.DiagnosticSource" version="4.5.1" targetFramework="net461" />
<package id="System.Diagnostics.StackTrace" version="4.3.0" targetFramework="net461" />
<package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="net461" />
<package id="System.IdentityModel.Tokens.Jwt" version="6.7.1" targetFramework="net461" />
<package id="System.IdentityModel.Tokens.Jwt" version="6.8.0" targetFramework="net461" />
<package id="System.IO" version="4.3.0" targetFramework="net461" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net461" />
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net461" />
......@@ -164,4 +170,5 @@
<package id="System.Threading.Thread" version="4.3.0" targetFramework="net461" />
<package id="System.Xml.ReaderWriter" version="4.3.1" targetFramework="net461" />
<package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="net461" />
<package id="VDS.Common" version="1.10.0" targetFramework="net461" />
</packages>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment