Skip to content
Snippets Groups Projects
Commit f3b4d43b authored by Marcel Nellesen's avatar Marcel Nellesen
Browse files

Merge branch 'Sprint/2020-22' into 'master'

Sprint/2020 22

See merge request coscine/cs/resourcetypebase!11
parents 15959294 9358bede
Branches
Tags v1.4.0
1 merge request!11Sprint/2020 22
Pipeline #399399 passed
Showing
with 133 additions and 37 deletions
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("ResourceTypeBase.Tests is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("ResourceTypeBase.Tests")]
[assembly: AssemblyVersion("1.2.0")]
[assembly: AssemblyFileVersion("1.2.0")]
[assembly: AssemblyInformationalVersion("1.2.0-topic-1032-resou0005")]
[assembly: AssemblyVersion("1.4.0")]
[assembly: AssemblyFileVersion("1.4.0")]
[assembly: AssemblyInformationalVersion("1.4.0-topic-1159-rtdap0012")]
[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")]
......@@ -43,6 +43,9 @@
<Reference Include="Coscine.Configuration, Version=1.5.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Configuration.1.5.0\lib\net461\Coscine.Configuration.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
......
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
......@@ -8,7 +9,6 @@ namespace Coscine.ResourceTypeBase.Tests
public class ResourceTypeBaseTest
{
private readonly string resourceTypeName = "rds";
private readonly Dictionary<string,string> resourceConfiguration = new Dictionary<string, string>();
private readonly string prefix = "prefix";
private readonly string key = "key";
......@@ -20,9 +20,11 @@ namespace Coscine.ResourceTypeBase.Tests
private readonly string entyName = "abc";
private readonly bool hasBody = true;
private readonly string[] versions = new string[1] {"1.0.0"};
private readonly long bodyBytes = 0;
private readonly string[] versions = new string[1] { "1.0.0" };
private readonly long bodyBytes = 0;
private readonly string pid = "00000000-0000-0000-0000-000000000000";
private readonly DateTime created = new DateTime();
private readonly DateTime modified = new DateTime();
[OneTimeSetUp]
public void Setup()
......@@ -38,19 +40,19 @@ namespace Coscine.ResourceTypeBase.Tests
[Test]
public void TestConstructorResourceEntry()
{
_ = new ResourceEntry(entyName, hasBody, bodyBytes, pid, versions);
_ = new ResourceEntry(entyName, hasBody, bodyBytes, pid, versions, created, modified);
}
[Test]
public void TestConstructorResourceTypeDefinition()
{
_ = new ResourceTypeDefinition(resourceTypeName, resourceConfiguration, null);
_ = new ResourceTypeDefinition(resourceTypeName, null, null);
}
[Test]
public async Task TestConstructorResourceTypeDefinitionEntry()
{
var resourceTypeDefinition = new ResourceTypeDefinition(resourceTypeName, resourceConfiguration, null);
var resourceTypeDefinition = new ResourceTypeDefinition(resourceTypeName, null, null);
await resourceTypeDefinition.ListEntries(id, prefix);
await resourceTypeDefinition.GetEntry(id, key);
await resourceTypeDefinition.StoreEntry(id, key, null);
......@@ -65,7 +67,7 @@ namespace Coscine.ResourceTypeBase.Tests
[Test]
public async Task TestConstructorResourceTypeDefinitionResourceAsync()
{
var resourceTypeDefinition = new ResourceTypeDefinition(resourceTypeName, resourceConfiguration, null);
var resourceTypeDefinition = new ResourceTypeDefinition(resourceTypeName, null, null);
await resourceTypeDefinition.CreateResource();
await resourceTypeDefinition.UpdateResource(id);
await resourceTypeDefinition.IsResourceCreated(id);
......
......@@ -2,6 +2,7 @@
<packages>
<package id="Consul" version="0.7.2.6" targetFramework="net461" />
<package id="Coscine.Configuration" version="1.5.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
<package id="NUnit" version="3.12.0" targetFramework="net461" />
<package id="NUnit3TestAdapter" version="3.17.0" targetFramework="net461" />
</packages>
\ No newline at end of file
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("ResourceTypeBase is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("ResourceTypeBase")]
[assembly: AssemblyVersion("1.2.0")]
[assembly: AssemblyFileVersion("1.2.0")]
[assembly: AssemblyInformationalVersion("1.2.0-topic-1032-resou0005")]
[assembly: AssemblyVersion("1.4.0")]
[assembly: AssemblyFileVersion("1.4.0")]
[assembly: AssemblyInformationalVersion("1.4.0-topic-1159-rtdap0012")]
[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Coscine.ResourceTypeBase
{
public class RTDBadRequestException : Exception
{
public RTDBadRequestException()
{
}
public RTDBadRequestException(string message)
: base(message)
{
}
public RTDBadRequestException(string message, Exception inner)
: base(message, inner)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Coscine.ResourceTypeBase
{
public class RTDForbiddenException : Exception
{
public RTDForbiddenException()
{
}
public RTDForbiddenException(string message)
: base(message)
{
}
public RTDForbiddenException(string message, Exception inner)
: base(message, inner)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Coscine.ResourceTypeBase
{
public class RTDNotFoundException : Exception
{
public RTDNotFoundException()
{
}
public RTDNotFoundException(string message)
: base(message)
{
}
public RTDNotFoundException(string message, Exception inner)
: base(message, inner)
{
}
}
}
......@@ -18,14 +18,19 @@ namespace Coscine.ResourceTypeBase
public string[] Versions { get; set; }
public ResourceEntry(string key, bool hasBody, long bodyBytes, string pid, string[] versions)
public DateTime? Modified { get; set; }
public DateTime? Created { get; set; }
public ResourceEntry(string key, bool hasBody, long bodyBytes, string pid, string[] versions, DateTime created, DateTime modified)
{
Key = key;
HasBody = hasBody;
BodyBytes = bodyBytes;
Pid = pid;
Versions = versions;
Created = created;
Modified = modified;
}
}
}
......@@ -41,6 +41,9 @@
<Reference Include="Coscine.Configuration, Version=1.5.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Configuration.1.5.0\lib\net461\Coscine.Configuration.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
......@@ -54,9 +57,13 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ResourceEntry.cs" />
<Compile Include="ResourceTypeConfigurationObject.cs" />
<Compile Include="ResourceTypeDefinition.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ResourceTypeInformation.cs" />
<Compile Include="RTDBadRequestException.cs" />
<Compile Include="RTDForbiddenException.cs" />
<Compile Include="RTDNotFoundException.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
......
using System.Collections.Generic;
namespace Coscine.ResourceTypeBase
{
public class ResourceTypeConfigurationObject
{
public Dictionary<string, string> Name { get; set; }
public string Path { get; set; }
public string ClassName { get; set; }
public string Status { get; set; }
public Dictionary<string, string> Config { get; set; }
public List<string> RequiredFields { get; set; }
}
}
......@@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Coscine.ResourceTypeBase
......@@ -11,17 +10,15 @@ namespace Coscine.ResourceTypeBase
{
public string Name { get; set; }
public Dictionary<string, string> Properties { get; set; }
public ResourceTypeConfigurationObject ResourceTypeConfiguration { get; set; }
public IConfiguration Configuration { get; set; }
public IConfiguration Configuration { get; set; }
protected readonly string _returnTypeClassName = null;
public ResourceTypeDefinition(string name, Dictionary<string, string> rConfig, IConfiguration gConfig)
public ResourceTypeDefinition(string name, IConfiguration gConfig, ResourceTypeConfigurationObject resourceTypeConfiguration)
{
Name = name;
Properties = rConfig;
Configuration = gConfig;
ResourceTypeConfiguration = resourceTypeConfiguration;
}
public virtual Task<List<ResourceEntry>> ListEntries(string id, string prefix, Dictionary<string, string> options = null)
......@@ -79,13 +76,12 @@ namespace Coscine.ResourceTypeBase
return Task.CompletedTask;
}
public virtual Task<ResourceTypeInformation> GetResourceTypeInformation(bool isEnabled, string displayName, Guid id)
public virtual Task<ResourceTypeInformation> GetResourceTypeInformation()
{
var resourceTypeInformation = new ResourceTypeInformation
{
IsEnabled = isEnabled,
DisplayName = displayName,
Id = id
IsEnabled = ResourceTypeConfiguration.Status == "active",
DisplayName = Name
};
var components = new List<List<string>>();
......@@ -93,15 +89,7 @@ namespace Coscine.ResourceTypeBase
{
components.Add(new List<string>());
}
if (_returnTypeClassName == null)
{
var listOfProperties = Type.GetType(_returnTypeClassName).GetProperties()
.Where((property) => property.Name != "Id")
.Select((property) => property.Name)
.ToList();
components[0] = listOfProperties;
}
components[0] = ResourceTypeConfiguration.RequiredFields;
resourceTypeInformation.ResourceCreate.Components = components;
return Task.FromResult(resourceTypeInformation);
......
......@@ -147,12 +147,12 @@ namespace Coscine.ResourceTypeBase
/// <summary>
/// A dataUrl canbe provided.
/// </summary>
public bool EditableDataUrl { get; set; } = true;
public bool EditableDataUrl { get; set; } = false;
/// <summary>
/// A key can be provided.
/// </summary>
public bool EditableKey { get; set; } = true;
public bool EditableKey { get; set; } = false;
/// <summary>
/// Standard constructor.
......
......@@ -2,4 +2,5 @@
<packages>
<package id="Consul" version="0.7.2.6" targetFramework="net461" />
<package id="Coscine.Configuration" version="1.5.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
</packages>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment