Aufgrund einer Wartung wird GitLab am 29.10. zwischen 9:00 und 10:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 29.10. between 9:00 and 10:00 am.

...
 
Commits (3)
......@@ -56,8 +56,8 @@
<Reference Include="Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL">
<HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath>
</Reference>
<Reference Include="Coscine.Action, Version=1.6.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.6.0\lib\net461\Coscine.Action.dll</HintPath>
<Reference Include="Coscine.Action, Version=1.7.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.7.0\lib\net461\Coscine.Action.dll</HintPath>
</Reference>
<Reference Include="Coscine.ApiCommons, Version=1.2.2.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ApiCommons.1.2.2\lib\net461\Coscine.ApiCommons.dll</HintPath>
......
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("Project.Tests is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("Project.Tests")]
[assembly: AssemblyVersion("1.8.0.0")]
[assembly: AssemblyFileVersion("1.8.0.0")]
[assembly: AssemblyInformationalVersion("1.8.0.0")]
[assembly: AssemblyVersion("1.9.0.0")]
[assembly: AssemblyFileVersion("1.9.0.0")]
[assembly: AssemblyInformationalVersion("1.9.0.0")]
[assembly: AssemblyCopyright("2019 IT Center, RWTH Aachen University")]
......@@ -4,7 +4,7 @@
<package id="AutoMapper.Extensions.Microsoft.DependencyInjection" version="6.0.0" targetFramework="net472" />
<package id="Castle.Core" version="4.4.0" targetFramework="net472" />
<package id="Consul" version="0.7.2.6" targetFramework="net472" />
<package id="Coscine.Action" version="1.6.0" targetFramework="net472" />
<package id="Coscine.Action" version="1.7.0" targetFramework="net472" />
<package id="Coscine.ApiCommons" version="1.2.2" targetFramework="net472" />
<package id="Coscine.Configuration" version="1.4.0" targetFramework="net472" />
<package id="Coscine.Database" version="1.10.0" targetFramework="net472" />
......
......@@ -39,13 +39,35 @@ namespace Coscine.Api.Project.Controllers
}));
}
[HttpGet("[controller]/resource/{resourceId}/ap/{applicationProfileId}")]
public IActionResult GetApplicationProfile(string resourceId, string applicationProfileId)
// returns the basic application profile
[HttpGet("[controller]/resource/{projectId}/ap/{applicationProfileId}")]
public IActionResult GetApplicationProfile(Guid projectId, string applicationProfileId)
{
var user = _authenticator.GetUserFromToken();
if (_metadataModel.IsProjectMember(user, projectId))
{
var graph = _util.GetGraph(HttpUtility.UrlDecode(applicationProfileId));
var json = JToken.Parse(VDS.RDF.Writing.StringWriter.Write(graph, new RdfJsonWriter()));
return Ok(json);
}
else
{
throw new NotAuthorizedException("User is no project member!");
}
}
// returns the application profile with the fixed values
[HttpGet("[controller]/resource/{resourceId}/apc/{applicationProfileId}")]
public IActionResult GetApplicationProfileComplete(string resourceId, string applicationProfileId)
{
var user = _authenticator.GetUserFromToken();
var resource = _resourceModel.GetById(Guid.Parse(resourceId));
if (_metadataModel.IsProjectMember(user, resource))
if (_metadataModel.IsProjectMember(user, resource) && applicationProfileId != null)
{
var graph = _util.GetGraph(HttpUtility.UrlDecode(applicationProfileId));
var fixedValuesGraph = new Graph();
......@@ -55,7 +77,7 @@ namespace Coscine.Api.Project.Controllers
graph.Merge(fixedValuesGraph);
var json = JToken.Parse(VDS.RDF.Writing.StringWriter.Write(graph, new RdfJsonWriter()));
return Ok(json);
}
else
......@@ -65,13 +87,12 @@ namespace Coscine.Api.Project.Controllers
}
[HttpGet("[controller]/resource/{resourceId}/aplist/")]
public IActionResult ListAllApplicationProfiles(string resourceId)
[HttpGet("[controller]/project/{projectId}/aplist/")]
public IActionResult ListAllApplicationProfiles(Guid projectId)
{
return Ok(_authenticator.ValidateAndExecute((user) =>
{
var resource = _resourceModel.GetById(Guid.Parse(resourceId));
if (_metadataModel.IsProjectMember(user, resource))
if (_metadataModel.IsProjectMember(user, projectId))
{
var graphUris = _util.ListGraphs();
......@@ -169,13 +190,12 @@ namespace Coscine.Api.Project.Controllers
}));
}
[HttpGet("[controller]/vocabulary/{resourceId}/{path}")]
public IActionResult GetVocabulary(string resourceId, string path)
[HttpGet("[controller]/vocabulary/{projectId}/{path}")]
public IActionResult GetVocabulary(Guid projectId, string path)
{
return Ok(_authenticator.ValidateAndExecute((user) =>
{
var resource = _resourceModel.GetById(Guid.Parse(resourceId));
if (_metadataModel.IsProjectMember(user, resource))
if (_metadataModel.IsProjectMember(user, projectId))
{
var graph = _util.GetGraph(HttpUtility.UrlDecode(path));
......
......@@ -21,6 +21,7 @@ namespace Coscine.Api.Project.Controllers
private readonly ProjectModel _projectModel;
private readonly IConfiguration _configuration;
private readonly Emitter _emitter;
public ProjectController()
{
_authenticator = new Authenticator(this, Program.Configuration);
......
......@@ -7,6 +7,9 @@ using Microsoft.AspNetCore.Mvc;
using System;
using System.Linq;
using Newtonsoft.Json.Linq;
using Coscine.Action;
using Coscine.Configuration;
using Coscine.Action.EventArgs;
namespace Coscine.Api.Project.Controllers
{
......@@ -14,11 +17,15 @@ namespace Coscine.Api.Project.Controllers
{
private readonly Authenticator _authenticator;
private readonly ResourceModel _resourceModel;
private readonly IConfiguration _configuration;
private readonly Emitter _emitter;
public ResourceController()
{
_authenticator = new Authenticator(this, Program.Configuration);
_configuration = Program.Configuration;
_resourceModel = new ResourceModel();
_emitter = new Emitter(this._configuration);
}
[Route("[controller]")]
......@@ -83,6 +90,10 @@ namespace Coscine.Api.Project.Controllers
if (_resourceModel.OwnsResource(user, resource))
{
var returnObject = _resourceModel.CreateReturnObjectFromDatabaseObject(resource);
_emitter.EmitResourceDelete(new ResourceEventArgs(_configuration)
{
Resource = resource
});
_resourceModel.DeleteResource(resource);
return returnObject;
}
......@@ -108,6 +119,11 @@ namespace Coscine.Api.Project.Controllers
projectModel.AddResource(project, resource);
_emitter.EmitResourceCreate(new ResourceEventArgs(_configuration)
{
Resource = resource
});
return _resourceModel.CreateReturnObjectFromDatabaseObject(resource);
}
else
......
......@@ -58,12 +58,24 @@ namespace Coscine.Api.Project.Models
return DatabaseConnection.ConnectToDatabase((db) =>
{
return (from relation in db.ProjectRoles
where relation.User == user
where relation.UserId == user.Id
&& (relation.Role.DisplayName == "Owner" || relation.Role.DisplayName == "Member")
&& (relation.Project.ProjectResourceProjectIdIds != null && relation.Project.ProjectResourceProjectIdIds.
Any((projectResource) => projectResource.Resource == resource))
select relation).Any();
});
}
public bool IsProjectMember(User user, Guid projectId)
{
return DatabaseConnection.ConnectToDatabase((db) =>
{
return (from relation in db.ProjectRoles
where relation.UserId == user.Id
&& (relation.Role.DisplayName == "Owner" || relation.Role.DisplayName == "Member")
&& (relation.ProjectId == projectId)
select relation).Any();
});
}
}
}
......@@ -192,9 +192,9 @@ namespace Coscine.Api.Project.Models
{
resource.LicenseId = resourceObject.License.Id;
}
resource.ApplicationProfile = resourceObject.ApplicationProfile;
resource.FixedValues = resourceObject.FixedValues.ToString();
// the application profile can not be altered after creation
// resource.ApplicationProfile = resourceObject.ApplicationProfile;
resource.FixedValues = resourceObject.FixedValues != null ? resourceObject.FixedValues.ToString() : "{}";
SetDisciplines(resource, resourceObject.Disciplines);
SetResourceTypeObject(resource, resourceObject.ResourceTypeOption);
......
......@@ -45,8 +45,8 @@
<Reference Include="Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL">
<HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath>
</Reference>
<Reference Include="Coscine.Action, Version=1.6.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.6.0\lib\net461\Coscine.Action.dll</HintPath>
<Reference Include="Coscine.Action, Version=1.7.0.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\Coscine.Action.1.7.0\lib\net461\Coscine.Action.dll</HintPath>
</Reference>
<Reference Include="Coscine.ApiCommons, Version=1.2.2.0, Culture=neutral, PublicKeyToken=af4c1345df96546b, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ApiCommons.1.2.2\lib\net461\Coscine.ApiCommons.dll</HintPath>
......
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("Project is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("Project")]
[assembly: AssemblyVersion("1.8.0.0")]
[assembly: AssemblyFileVersion("1.8.0.0")]
[assembly: AssemblyInformationalVersion("1.8.0.0")]
[assembly: AssemblyVersion("1.9.0.0")]
[assembly: AssemblyFileVersion("1.9.0.0")]
[assembly: AssemblyInformationalVersion("1.9.0.0")]
[assembly: AssemblyCopyright("2019 IT Center, RWTH Aachen University")]
......@@ -9,6 +9,7 @@ namespace Coscine.Api.Project.ReturnObjects
public class ResourceObject : IReturnObject
{
public Guid Id { get; set; }
public string PID { get { return Program.Configuration.GetStringAndWait("coscine/global/epic/prefix") + "/" + Id.ToString(); } }
public string DisplayName { get; set; }
public string ResourceName { get; set; }
public string Description { get; set; }
......
......@@ -3,7 +3,7 @@
<package id="AutoMapper" version="8.0.0" targetFramework="net472" />
<package id="AutoMapper.Extensions.Microsoft.DependencyInjection" version="6.0.0" targetFramework="net472" />
<package id="Consul" version="0.7.2.6" targetFramework="net472" />
<package id="Coscine.Action" version="1.6.0" targetFramework="net472" />
<package id="Coscine.Action" version="1.7.0" targetFramework="net472" />
<package id="Coscine.ApiCommons" version="1.2.2" targetFramework="net472" />
<package id="Coscine.Configuration" version="1.4.0" targetFramework="net472" />
<package id="Coscine.Database" version="1.10.0" targetFramework="net472" />
......