Commit 4b5fecd5 authored by L. Ellenbeck's avatar L. Ellenbeck Committed by Marcel Nellesen

New: Created external Api (coscine/issues#313)

parent 548b9675
......@@ -24,7 +24,11 @@ var solutionFile = GetFiles("./**/*.sln").First();
var projectName = solutionFile.GetFilenameWithoutExtension().ToString();
var assemblyInfoSubPath = "Properties/AssemblyInfo.cs";
var nugetSource = "https://api.nuget.org/v3/index.json";
var localNugetFeed = new
{
Name = "LocalNuget",
Source = @"C:\LocalNuget"
};
// get latest MSBuild version
var vsLatest = VSWhereLatest();
var msBuildPathX64 = (vsLatest == null) ? null : vsLatest.CombineWithFilePath("./MSBuild/Current/Bin/MSBuild.exe");
......@@ -89,6 +93,10 @@ Task("Restore")
.Does(() =>{
// Restore all NuGet packages.
Information($"Restoring {solutionFile}...");
if(!NuGetHasSource(localNugetFeed.Source))
{
NuGetAddSource(localNugetFeed.Name, localNugetFeed.Source);
}
NuGetRestore(solutionFile, new NuGetRestoreSettings {
NoCache = true
});
......@@ -103,7 +111,7 @@ Task("DupFinder")
OutputFile = $"{artifactsDir}/dupfinder.xml",
ExcludeCodeRegionsByNameSubstring = dupFinderExcludeCodeRegionsByNameSubstring,
ExcludePattern = dupFinderExcludePatterns.ToArray(),
ThrowExceptionOnFindingDuplicates = true
ThrowExceptionOnFindingDuplicates = false
};
DupFinder(solutionFile, settings);
});
......
......@@ -74,18 +74,30 @@
<Reference Include="Coscine.SharePoint.Webparts.Vue, Version=1.4.0.0, Culture=neutral, PublicKeyToken=0fe8d3e516df6d98, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.SharePoint.Webparts.Vue.1.4.0\lib\net461\Coscine.SharePoint.Webparts.Vue.dll</HintPath>
</Reference>
<Reference Include="dotNetRDF, Version=2.2.1.0, Culture=neutral, PublicKeyToken=6055ffe4c97cc780, processorArchitecture=MSIL">
<HintPath>..\packages\dotNetRDF.2.2.1\lib\net40\dotNetRDF.dll</HintPath>
</Reference>
<Reference Include="dotNetRDF.Data.Virtuoso, Version=2.2.1.0, Culture=neutral, PublicKeyToken=6055ffe4c97cc780, processorArchitecture=MSIL">
<HintPath>..\packages\dotNetRDF.Data.Virtuoso.2.2.1\lib\net40\dotNetRDF.Data.Virtuoso.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.8.2.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.8.2\lib\Net45\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="linq2db, Version=2.6.4.0, Culture=neutral, PublicKeyToken=e41013125f9e410a, processorArchitecture=MSIL">
<HintPath>..\packages\linq2db.2.6.4\lib\net46\linq2db.dll</HintPath>
</Reference>
<Reference Include="LinqKit, Version=1.1.16.0, Culture=neutral, PublicKeyToken=bc217f8844052a91, processorArchitecture=MSIL">
<HintPath>..\packages\LinqKit.1.1.16\lib\net45\LinqKit.dll</HintPath>
</Reference>
<Reference Include="Metadata, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Metadata.1.0.0\lib\net461\Metadata.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNetCore.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.dll</HintPath>
</Reference>
......@@ -350,14 +362,14 @@
<Reference Include="microsoft.identitymodel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.7.0.0\lib\net35\microsoft.identitymodel.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=5.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.JsonWebTokens.5.5.0\lib\net461\Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.JsonWebTokens.5.6.0\lib\net461\Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Logging, Version=5.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Logging.5.5.0\lib\net461\Microsoft.IdentityModel.Logging.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Logging, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Logging.5.6.0\lib\net461\Microsoft.IdentityModel.Logging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Tokens.5.5.0\lib\net461\Microsoft.IdentityModel.Tokens.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Tokens.5.6.0\lib\net461\Microsoft.IdentityModel.Tokens.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Net.Http.Headers, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.Headers.2.2.0\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll</HintPath>
......@@ -416,8 +428,8 @@
<Private>True</Private>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.IdentityModel.Tokens.Jwt.5.5.0\lib\net461\System.IdentityModel.Tokens.Jwt.dll</HintPath>
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.IdentityModel.Tokens.Jwt.5.6.0\lib\net461\System.IdentityModel.Tokens.Jwt.dll</HintPath>
</Reference>
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
......@@ -560,6 +572,12 @@
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="VDS.Common, Version=1.10.0.0, Culture=neutral, PublicKeyToken=ab5f4eb908061bf0, processorArchitecture=MSIL">
<HintPath>..\packages\VDS.Common.1.10.0\lib\net40-client\VDS.Common.dll</HintPath>
</Reference>
<Reference Include="virtado4, Version=4.0.0.0, Culture=neutral, PublicKeyToken=391bf132017ae989, processorArchitecture=MSIL">
<HintPath>..\packages\OpenLink.Data.Virtuoso.7.20.3214.1\lib\net40\virtado4.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DefaultControllerTests.cs" />
......
......@@ -97,7 +97,9 @@ namespace Coscine.Api.Project.Tests
new List<DisciplineObject>() { new DisciplineObject(Discipline.Id, Discipline.Url, Discipline.DisplayNameDe, Discipline.DisplayNameEn) },
new VisibilityObject(Visibility.Id, Visibility.DisplayName),
new LicenseObject(License.Id, License.DisplayName),
JObject.FromObject(new RDSResourceTypeObject(Guid.NewGuid(), "PITLABTTEST", "accesskey", "secretkey"))
JObject.FromObject(new RDSResourceTypeObject(Guid.NewGuid(), "PITLABTTEST", "accesskey", "secretkey")),
"link",
JToken.Parse("{}")
);
Stream stream = ObjectFactory<ResourceObject>.SerializeToStream(resourceObject);
......
......@@ -92,11 +92,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
<bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Tokens" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
<bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Coscine.SharePoint.Webparts.Vue" publicKeyToken="0fe8d3e516df6d98" culture="neutral" />
......
......@@ -10,11 +10,15 @@
<package id="Coscine.Database" version="1.9.0" targetFramework="net472" />
<package id="Coscine.ProxyApi" version="1.2.0" targetFramework="net472" />
<package id="Coscine.SharePoint.Webparts.Vue" version="1.4.0" targetFramework="net472" />
<package id="dotNetRDF" version="2.2.1" targetFramework="net472" />
<package id="dotNetRDF.Data.Virtuoso" version="2.2.1" targetFramework="net472" />
<package id="EntityFramework" version="6.2.0" targetFramework="net472" />
<package id="HtmlAgilityPack" version="1.8.2" targetFramework="net472" />
<package id="linq2db" version="2.6.4" targetFramework="net472" />
<package id="linq2db.SqlServer" version="2.6.4" targetFramework="net472" />
<package id="linq2db.t4models" version="2.6.4" targetFramework="net472" />
<package id="LinqKit" version="1.1.16" targetFramework="net472" />
<package id="Metadata" version="1.0.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Antiforgery" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Authentication.Abstractions" version="2.2.0" targetFramework="net472" />
......@@ -108,9 +112,9 @@
<package id="Microsoft.Extensions.Primitives" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.Extensions.WebEncoders" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel" version="7.0.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Logging" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Tokens" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.6.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Logging" version="5.6.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Tokens" version="5.6.0" targetFramework="net472" />
<package id="Microsoft.Net.Http.Headers" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.Win32.Registry" version="4.5.0" targetFramework="net472" />
<package id="Moq" version="4.12.0" targetFramework="net472" />
......@@ -118,6 +122,7 @@
<package id="Newtonsoft.Json.Bson" version="1.0.2" targetFramework="net472" />
<package id="NUnit" version="3.11.0" targetFramework="net472" />
<package id="NUnit3TestAdapter" version="3.13.0" targetFramework="net472" />
<package id="OpenLink.Data.Virtuoso" version="7.20.3214.1" targetFramework="net472" />
<package id="System.AppContext" version="4.3.0" targetFramework="net472" />
<package id="System.Buffers" version="4.5.0" targetFramework="net472" />
<package id="System.Collections" version="4.3.0" targetFramework="net472" />
......@@ -129,7 +134,7 @@
<package id="System.Diagnostics.FileVersionInfo" version="4.3.0" targetFramework="net472" />
<package id="System.Diagnostics.StackTrace" version="4.3.0" targetFramework="net472" />
<package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="net472" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.5.0" targetFramework="net472" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.6.0" targetFramework="net472" />
<package id="System.IO" version="4.3.0" targetFramework="net472" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net472" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net472" />
......@@ -162,4 +167,5 @@
<package id="System.Xml.ReaderWriter" version="4.3.1" targetFramework="net472" />
<package id="System.Xml.XPath" version="4.3.0" targetFramework="net472" />
<package id="System.Xml.XPath.XDocument" version="4.3.0" targetFramework="net472" />
<package id="VDS.Common" version="1.10.0" targetFramework="net472" />
</packages>
\ No newline at end of file
......@@ -95,11 +95,11 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
<bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Tokens" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.5.0.0" newVersion="5.5.0.0" />
<bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Coscine.SharePoint.Webparts.Vue" publicKeyToken="0fe8d3e516df6d98" culture="neutral" />
......
using Coscine.Api.Project.Models;
using Coscine.ApiCommons;
using Coscine.ApiCommons.Exceptions;
using Coscine.ApiCommons.Factories;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using System;
using System.Linq;
using VDS.RDF.Writing;
using VDS.RDF.Parsing;
using VDS.RDF;
using Metadata;
using System.Web;
using System.IO;
namespace Coscine.Api.Project.Controllers
{
public class MetadataController : Controller
{
private readonly Authenticator _authenticator;
private readonly MetadataModel _metadataModel;
private readonly ResourceModel _resourceModel;
private readonly Util _util;
public MetadataController()
{
_authenticator = new Authenticator(this, Program.Configuration);
_metadataModel = new MetadataModel();
_resourceModel = new ResourceModel();
_util = new Util();
}
[Route("[controller]")]
public IActionResult Index()
{
return Ok(_authenticator.ValidateAndExecute((user) =>
{
return NoContent();
}));
}
[HttpGet("[controller]/resource/{resourceId}/ap/{applicationProfileId}")]
public IActionResult GetApplicationProfile(string resourceId, string applicationProfileId)
{
var user = _authenticator.GetUserFromToken();
var resource = _resourceModel.GetById(Guid.Parse(resourceId));
if (_metadataModel.IsProjectMember(user, resource))
{
var graph = _util.GetGraph(HttpUtility.UrlDecode(applicationProfileId));
var fixedValuesGraph = new Graph();
fixedValuesGraph.LoadFromString(resource.FixedValues, new RdfJsonParser());
graph.Merge(fixedValuesGraph);
var json = JToken.Parse(VDS.RDF.Writing.StringWriter.Write(graph, new RdfJsonWriter()));
return Ok(json);
}
else
{
throw new NotAuthorizedException("User is no project member!");
}
}
[HttpGet("[controller]/resource/{resourceId}/aplist/")]
public IActionResult ListAllApplicationProfiles(string resourceId)
{
return Ok(_authenticator.ValidateAndExecute((user) =>
{
var resource = _resourceModel.GetById(Guid.Parse(resourceId));
if (_metadataModel.IsProjectMember(user, resource))
{
var graphUris = _util.ListGraphs();
return new JArray(graphUris.Select(x => x.ToString()).Where(x => x.StartsWith("https://purl.org/coscine/ap/")));
}
else
{
throw new NotAuthorizedException("User is no project member!");
}
}));
}
[HttpGet("[controller]/resource/{resourceId}/filename/{filename}/ver/{version}")]
public IActionResult GetMetadataForFile(string resourceId, string filename, string version)
{
return Ok(_authenticator.ValidateAndExecute((user) =>
{
var resource = _resourceModel.GetById(Guid.Parse(resourceId));
if (_metadataModel.IsProjectMember(user, resource))
{
var id = _metadataModel.GenerateId(resourceId, filename, version);
var graph = _util.GetGraph(id);
return JToken.Parse(VDS.RDF.Writing.StringWriter.Write(graph, new RdfJsonWriter()));
}
else
{
throw new NotAuthorizedException("User is no project member!");
}
}));
}
[HttpPut("[controller]/resource/{resourceId}/filename/{filename}/ver/{version}")]
public IActionResult StoreMetadataForFile(string resourceId, string filename, string version)
{
return Ok(_authenticator.ValidateAndExecute((user) =>
{
var innerBlock = ObjectFactory<JToken>.DeserializeFromStream(Request.Body);
var graphName = _metadataModel.GenerateId(resourceId, filename, version);
var graphNameUri = new Uri(graphName);
var json = new JObject
{
[graphName] = innerBlock
};
var resource = _resourceModel.GetById(Guid.Parse(resourceId));
if (_metadataModel.IsProjectMember(user, resource))
{
var graph = new Graph();
graph.LoadFromString(json.ToString(), new RdfJsonParser());
var fixedValuesGraph = new Graph();
fixedValuesGraph.LoadFromString(resource.FixedValues, new RdfJsonParser());
foreach(var triple in fixedValuesGraph.Triples.Where(x => x.Predicate.ToString() == "https://purl.org/coscine/fixedValue"))
{
// Remove any existing triples
foreach (var triple2 in graph.GetTriplesWithSubjectPredicate(graph.CreateUriNode(graphNameUri), triple.Subject).ToList())
{
graph.Retract(triple2);
}
graph.Assert(graph.CreateUriNode(graphNameUri), triple.Subject, triple.Object);
}
// Default values is not checked or added
// validate the data
if (_util.ValidateShacl(graph, graphNameUri))
{
// store the data
if (_util.HasGraph(graphNameUri))
{
_util.ClearGraph(graphNameUri);
}
else
{
_util.CreateNamedGraph(graphNameUri);
}
// BaseUri must be set for the sparql query
graph.BaseUri = graphNameUri;
_util.AddGraph(graph);
return NoContent();
}
else
{
throw new NotAuthorizedException("Data has the wrong format!");
}
}
else
{
throw new NotAuthorizedException("User is no project member!");
}
}));
}
[HttpGet("[controller]/vocabulary/{resourceId}/{path}")]
public IActionResult GetVocabulary(string resourceId, string path)
{
return Ok(_authenticator.ValidateAndExecute((user) =>
{
var resource = _resourceModel.GetById(Guid.Parse(resourceId));
if (_metadataModel.IsProjectMember(user, resource))
{
var graph = _util.GetGraph(HttpUtility.UrlDecode(path));
JArray de = new JArray();
foreach (var kv in _util.GetVocabularyLabels(graph, "de"))
{
JObject obj = new JObject
{
["value"] = kv.Key,
["name"] = kv.Value
};
de.Add(obj);
}
JArray en = new JArray();
foreach(var kv in _util.GetVocabularyLabels(graph, "en"))
{
JObject obj = new JObject
{
["value"] = kv.Key,
["name"] = kv.Value
};
en.Add(obj);
}
JObject json = new JObject
{
["de"] = de,
["en"] = en
};
return json;
}
else
{
throw new NotAuthorizedException("User is no project member!");
}
}));
}
}
}
......@@ -3,10 +3,10 @@ using Coscine.Api.Project.ReturnObjects;
using Coscine.ApiCommons;
using Coscine.ApiCommons.Exceptions;
using Coscine.ApiCommons.Factories;
using Coscine.Database.Model;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Linq;
using Newtonsoft.Json.Linq;
namespace Coscine.Api.Project.Controllers
{
......@@ -116,6 +116,5 @@ namespace Coscine.Api.Project.Controllers
}
}));
}
}
}
using Coscine.Api.Project.ReturnObjects;
using Coscine.ApiCommons.Models;
using Coscine.Database.Model;
using LinqToDB;
using System;
using System.Linq;
using System.Linq.Expressions;
namespace Coscine.Api.Project.Models
{
public class MetadataModel : DatabaseModel<Resource>
{
public MetadataModel() : base(Program.Configuration)
{
}
public override Expression<Func<Resource, Guid>> GetIdFromObject()
{
throw new NotImplementedException();
}
public override void SetObjectId(Resource databaseObject, Guid id)
{
throw new NotImplementedException();
}
public override ITable<Resource> GetITableFromDatabase(CoscineDB db)
{
throw new NotImplementedException();
}
public Resource StoreFromObject(ResourceObject resourceObject)
{
Resource resource = new Resource()
{
DisplayName = resourceObject.DisplayName,
ResourceName = resourceObject.ResourceName,
Keywords = resourceObject.Keywords,
UsageRights = resourceObject.UsageRights,
TypeId = resourceObject.Type.Id,
Type = new ResourceTypeModel().GetById(resourceObject.Type.Id),
VisibilityId = resourceObject.Visibility.Id,
LicenseId = resourceObject.License.Id
};
return resource;
}
public string GenerateId(string resourceId, string filename, string version)
{
return $"https://purl.org/coscine/md/{resourceId}/{filename}/{version}/";
}
public bool IsProjectMember(User user, Resource resource)
{
return DatabaseConnection.ConnectToDatabase((db) =>
{
return (from relation in db.ProjectRoles
where relation.User == user
&& (relation.Role.DisplayName == "Owner" || relation.Role.DisplayName == "Member")
&& (relation.Project.ProjectResourceProjectIdIds != null && relation.Project.ProjectResourceProjectIdIds.
Any((projectResource) => projectResource.Resource == resource))
select relation).Any();
});
}
}
}
......@@ -14,7 +14,6 @@ namespace Coscine.Api.Project.Models
{
public ResourceModel() : base(Program.Configuration)
{
}
public Resource StoreFromObject(ResourceObject resourceObject)
......@@ -167,7 +166,7 @@ namespace Coscine.Api.Project.Models
select relation).Any();
});
}
public int UpdateByObject(Resource resource, ResourceObject resourceObject)
{
if (resourceObject.Disciplines.Count() == 0 || resourceObject.ResourceTypeOption == null)
......@@ -193,6 +192,8 @@ namespace Coscine.Api.Project.Models
resource.LicenseId = resourceObject.License.Id;
}
resource.ApplicationProfile = resourceObject.ApplicationProfile;
resource.FixedValues = resourceObject.FixedValues.ToString();
SetDisciplines(resource, resourceObject.Disciplines);
SetResourceTypeObject(resource, resourceObject.ResourceTypeOption);
......@@ -273,7 +274,9 @@ namespace Coscine.Api.Project.Models
disciplines,
(resource.Visibility != null) ? new VisibilityObject(resource.Visibility.Id, resource.Visibility.DisplayName) : null,
(resource.License != null) ? new LicenseObject(resource.License.Id, resource.License.DisplayName) : null,
JObject.FromObject(resourceTypeOptionObject)
JObject.FromObject(resourceTypeOptionObject),
resource.ApplicationProfile,
JToken.Parse(resource.FixedValues)
);
}
......
......@@ -63,18 +63,30 @@
<Reference Include="Coscine.SharePoint.Webparts.Vue, Version=1.4.0.0, Culture=neutral, PublicKeyToken=0fe8d3e516df6d98, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.SharePoint.Webparts.Vue.1.4.0\lib\net461\Coscine.SharePoint.Webparts.Vue.dll</HintPath>
</Reference>
<Reference Include="dotNetRDF, Version=2.2.1.0, Culture=neutral, PublicKeyToken=6055ffe4c97cc780, processorArchitecture=MSIL">
<HintPath>..\packages\dotNetRDF.2.2.1\lib\net40\dotNetRDF.dll</HintPath>
</Reference>
<Reference Include="dotNetRDF.Data.Virtuoso, Version=2.2.1.0, Culture=neutral, PublicKeyToken=6055ffe4c97cc780, processorArchitecture=MSIL">
<HintPath>..\packages\dotNetRDF.Data.Virtuoso.2.2.1\lib\net40\dotNetRDF.Data.Virtuoso.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.8.2.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.8.2\lib\Net45\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="linq2db, Version=2.6.4.0, Culture=neutral, PublicKeyToken=e41013125f9e410a, processorArchitecture=MSIL">
<HintPath>..\packages\linq2db.2.6.4\lib\net46\linq2db.dll</HintPath>
</Reference>
<Reference Include="LinqKit, Version=1.1.16.0, Culture=neutral, PublicKeyToken=bc217f8844052a91, processorArchitecture=MSIL">
<HintPath>..\packages\LinqKit.1.1.16\lib\net45\LinqKit.dll</HintPath>
</Reference>
<Reference Include="Metadata, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Metadata.1.0.0\lib\net461\Metadata.dll</HintPath>
</Reference>
<Reference Include="Microsoft.AspNetCore, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNetCore.2.2.0\lib\netstandard2.0\Microsoft.AspNetCore.dll</HintPath>
</Reference>
......@@ -344,14 +356,14 @@
<Reference Include="microsoft.identitymodel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.7.0.0\lib\net35\microsoft.identitymodel.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=5.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.JsonWebTokens.5.5.0\lib\net461\Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.JsonWebTokens.5.6.0\lib\net461\Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Logging, Version=5.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Logging.5.5.0\lib\net461\Microsoft.IdentityModel.Logging.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Logging, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Logging.5.6.0\lib\net461\Microsoft.IdentityModel.Logging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Tokens.5.5.0\lib\net461\Microsoft.IdentityModel.Tokens.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.Tokens.5.6.0\lib\net461\Microsoft.IdentityModel.Tokens.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Net.Http.Headers, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Net.Http.Headers.2.2.0\lib\netstandard2.0\Microsoft.Net.Http.Headers.dll</HintPath>
......@@ -384,6 +396,7 @@
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Console, Version=4.0.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Console.4.3.1\lib\net46\System.Console.dll</HintPath>
<Private>True</Private>
......@@ -405,8 +418,8 @@
<Private>True</Private>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.IdentityModel.Tokens.Jwt.5.5.0\lib\net461\System.IdentityModel.Tokens.Jwt.dll</HintPath>
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.IdentityModel.Tokens.Jwt.5.6.0\lib\net461\System.IdentityModel.Tokens.Jwt.dll</HintPath>
</Reference>
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
......@@ -564,9 +577,16 @@
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="VDS.Common, Version=1.10.0.0, Culture=neutral, PublicKeyToken=ab5f4eb908061bf0, processorArchitecture=MSIL">
<HintPath>..\packages\VDS.Common.1.10.0\lib\net40-client\VDS.Common.dll</HintPath>
</Reference>
<Reference Include="virtado4, Version=4.0.0.0, Culture=neutral, PublicKeyToken=391bf132017ae989, processorArchitecture=MSIL">
<HintPath>..\packages\OpenLink.Data.Virtuoso.7.20.3214.1\lib\net40\virtado4.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\DataSourceController.cs" />
<Compile Include="Controllers\MetadataController.cs" />
<Compile Include="Controllers\LicenseController.cs" />
<Compile Include="Controllers\VisibilityController.cs" />
<Compile Include="Controllers\InstituteController.cs" />
......@@ -588,6 +608,7 @@
<Compile Include="Models\ProjectRoleModel.cs" />
<Compile Include="Models\RDSResourceTypeModel.cs" />
<Compile Include="Models\ResourceDisciplineModel.cs" />
<Compile Include="Models\MetadataModel.cs" />
<Compile Include="Models\ResourceModel.cs" />
<Compile Include="Models\ResourceTypeModel.cs" />
<Compile Include="Models\RoleModel.cs" />
......
......@@ -19,8 +19,10 @@ namespace Coscine.Api.Project.ReturnObjects
public VisibilityObject Visibility { get; set; }
public LicenseObject License { get; set; }
public JObject ResourceTypeOption { get; set; }
public string ApplicationProfile { get; set; }
public JToken FixedValues { get; set; }
public ResourceObject(Guid id, string displayName, string resourceName, string description, string keywords, string usageRights, ResourceTypeObject type, IEnumerable<DisciplineObject> disciplines, VisibilityObject visibility, LicenseObject license, JObject resourceTypeOption)
public ResourceObject(Guid id, string displayName, string resourceName, string description, string keywords, string usageRights, ResourceTypeObject type, IEnumerable<DisciplineObject> disciplines, VisibilityObject visibility, LicenseObject license, JObject resourceTypeOption, string applicationProfile, JToken fixedValues)
{
Id = id;
......@@ -36,6 +38,9 @@ namespace Coscine.Api.Project.ReturnObjects
License = license;
ResourceTypeOption = resourceTypeOption;
ApplicationProfile = applicationProfile;
FixedValues = fixedValues;
}
}
}
......@@ -9,11 +9,15 @@
<package id="Coscine.Database" version="1.9.0" targetFramework="net472" />
<package id="Coscine.ProxyApi" version="1.2.0" targetFramework="net472" />
<package id="Coscine.SharePoint.Webparts.Vue" version="1.4.0" targetFramework="net472" />
<package id="dotNetRDF" version="2.2.1" targetFramework="net472" />
<package id="dotNetRDF.Data.Virtuoso" version="2.2.1" targetFramework="net472" />
<package id="EntityFramework" version="6.2.0" targetFramework="net472" />
<package id="HtmlAgilityPack" version="1.8.2" targetFramework="net472" />
<package id="linq2db" version="2.6.4" targetFramework="net472" />
<package id="linq2db.SqlServer" version="2.6.4" targetFramework="net472" />
<package id="linq2db.t4models" version="2.6.4" targetFramework="net472" />
<package id="LinqKit" version="1.1.16" targetFramework="net472" />
<package id="Metadata" version="1.0.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Antiforgery" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.AspNetCore.Authentication.Abstractions" version="2.2.0" targetFramework="net472" />
......@@ -107,13 +111,14 @@
<package id="Microsoft.Extensions.Primitives" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.Extensions.WebEncoders" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel" version="7.0.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Logging" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Tokens" version="5.5.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.6.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Logging" version="5.6.0" targetFramework="net472" />
<package id="Microsoft.IdentityModel.Tokens" version="5.6.0" targetFramework="net472" />
<package id="Microsoft.Net.Http.Headers" version="2.2.0" targetFramework="net472" />
<package id="Microsoft.Win32.Registry" version="4.5.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
<package id="Newtonsoft.Json.Bson" version="1.0.2" targetFramework="net472" />
<package id="OpenLink.Data.Virtuoso" version="7.20.3214.1" targetFramework="net472" />
<package id="System.AppContext" version="4.3.0" targetFramework="net472" />
<package id="System.Buffers" version="4.5.0" targetFramework="net472" />
<package id="System.Collections" version="4.3.0" targetFramework="net472" />
......@@ -128,7 +133,7 @@
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net472" />
<package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="net472" />
<package id="System.Globalization" version="4.3.0" targetFramework="net472" />