diff --git a/src/ProxyApi/MetadataApiConnector.cs b/src/ProxyApi/MetadataApiConnector.cs index f30e18824fed887b41eef346549c507e736034ef..8266d63157e58300af5dee9a62421130177e2451 100644 --- a/src/ProxyApi/MetadataApiConnector.cs +++ b/src/ProxyApi/MetadataApiConnector.cs @@ -1,10 +1,8 @@ -using System; -using System.Collections.Generic; -using System.IO; +using System.Collections.Generic; using System.Net; using System.Net.Http; -using System.Runtime.Serialization; using System.Threading.Tasks; +using Coscine.ProxyApi.Utils; using Newtonsoft.Json; namespace Coscine.ProxyApi @@ -26,7 +24,7 @@ namespace Coscine.ProxyApi this._apiConnector = apiConnector; } - public Dictionary<string, List<PropertyDescription>> CreateMetadata(string currentPath, List<string> metadataUris, List<string> metadataTypes, string longSchemaPath) + public Dictionary<string, List<PropertyDescription>> CreateMetadata(string currentPath, List<string> metadataUris, List<string> metadataTypes, Dictionary<string, PropertyDescription> metadataConstants, string longSchemaPath) { Dictionary<string, List<PropertyDescription>> metadataSet = new Dictionary<string, List<PropertyDescription>>(); string[] schemaFolders = longSchemaPath.Substring(currentPath.Length).Trim('\\').Split('\\'); @@ -43,6 +41,15 @@ namespace Coscine.ProxyApi metadataSet[uri].Add(new PropertyDescription(folderName, propertyType)); } + foreach(var constant in metadataConstants) + { + if (!metadataSet.ContainsKey(constant.Key)) + { + metadataSet.Add(constant.Key, new List<PropertyDescription>()); + } + metadataSet[constant.Key].Add(constant.Value); + } + AddDefaultMetadata(metadataSet); return metadataSet; @@ -142,20 +149,5 @@ namespace Coscine.ProxyApi return await client.GetAsync(url); } - [DataContract] - public class PropertyDescription - { - [DataMember] - public string Value { get; set; } - [DataMember] - public string Type { get; set; } - - public PropertyDescription(string value, string type) - { - this.Value = value; - this.Type = type; - } - } - } } diff --git a/src/ProxyApi/ProxyApi.csproj b/src/ProxyApi/ProxyApi.csproj index efb93067abfa636444c57a5b9168fac5ce7ef329..e01013155d4928e2cf697b5bfa25936b81db1240 100644 --- a/src/ProxyApi/ProxyApi.csproj +++ b/src/ProxyApi/ProxyApi.csproj @@ -81,6 +81,7 @@ <Compile Include="Utils\Json.cs" /> <Compile Include="Utils\MockupWebRequest.cs" /> <Compile Include="Utils\OAuth2Client.cs" /> + <Compile Include="Utils\PropertyDescription.cs" /> <Compile Include="Utils\RestClient.cs" /> <Compile Include="Utils\ServiceObject.cs" /> </ItemGroup> diff --git a/src/ProxyApi/Utils/PropertyDescription.cs b/src/ProxyApi/Utils/PropertyDescription.cs new file mode 100644 index 0000000000000000000000000000000000000000..dd34acc49385ce94a9abeff0aec486859b5d8b45 --- /dev/null +++ b/src/ProxyApi/Utils/PropertyDescription.cs @@ -0,0 +1,19 @@ +using System.Runtime.Serialization; + +namespace Coscine.ProxyApi.Utils +{ + [DataContract] + public class PropertyDescription + { + [DataMember] + public string Value { get; set; } + [DataMember] + public string Type { get; set; } + + public PropertyDescription(string value, string type) + { + this.Value = value; + this.Type = type; + } + } +}