Skip to content

Commit 6661703

Browse files
committed
Added Zone and Context using Matrix Parameters
Upgraded Web API to version 5.2.3 on all appropriate projects. Enhanced and configured the WebApi implementation to recognise Matrix Parameters. Updated Consumers to pass Zone and Context with all requests using Matrix Parameters. Updated Providers to handle receiving Zone and Context as Matrix Parameters. Updated AU and US demo projects to reflect the use of Matrix Parameters.
1 parent 7af3e01 commit 6661703

45 files changed

Lines changed: 1030 additions & 238 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Code/Sif3Framework/Sif.Framework.EnvironmentProvider/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
//
3232
// You can specify all the values or you can default the Revision and Build Numbers
3333
// by using the '*' as shown below:
34-
[assembly: AssemblyVersion("1.0.0.0")]
35-
[assembly: AssemblyFileVersion("1.0.0.0")]
34+
[assembly: AssemblyVersion("1.1.0.0")]
35+
[assembly: AssemblyFileVersion("1.1.0.0")]

Code/Sif3Framework/Sif.Framework.EnvironmentProvider/Sif.Framework.EnvironmentProvider.csproj

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<IISExpressAnonymousAuthentication />
2020
<IISExpressWindowsAuthentication />
2121
<IISExpressUseClassicPipelineMode />
22+
<UseGlobalApplicationHostFile />
2223
</PropertyGroup>
2324
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2425
<DebugSymbols>true</DebugSymbols>
@@ -61,9 +62,9 @@
6162
<HintPath>..\packages\System.Data.SQLite.Core.1.0.94.0\lib\net45\System.Data.SQLite.dll</HintPath>
6263
</Reference>
6364
<Reference Include="System.Net.Http" />
64-
<Reference Include="System.Net.Http.Formatting, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
65-
<SpecificVersion>False</SpecificVersion>
66-
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.2\lib\net45\System.Net.Http.Formatting.dll</HintPath>
65+
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
66+
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
67+
<Private>True</Private>
6768
</Reference>
6869
<Reference Include="System.Web.DynamicData" />
6970
<Reference Include="System.Web.Entity" />
@@ -74,13 +75,13 @@
7475
<Reference Include="System.Core" />
7576
<Reference Include="System.Data.DataSetExtensions" />
7677
<Reference Include="System.Web.Extensions" />
77-
<Reference Include="System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
78-
<SpecificVersion>False</SpecificVersion>
79-
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.2\lib\net45\System.Web.Http.dll</HintPath>
78+
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
79+
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
80+
<Private>True</Private>
8081
</Reference>
81-
<Reference Include="System.Web.Http.WebHost, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
82-
<SpecificVersion>False</SpecificVersion>
83-
<HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.2\lib\net45\System.Web.Http.WebHost.dll</HintPath>
82+
<Reference Include="System.Web.Http.WebHost, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
83+
<HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.3\lib\net45\System.Web.Http.WebHost.dll</HintPath>
84+
<Private>True</Private>
8485
</Reference>
8586
<Reference Include="System.Xml.Linq" />
8687
<Reference Include="System.Drawing" />

Code/Sif3Framework/Sif.Framework.EnvironmentProvider/packages.config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Iesi.Collections" version="4.0.1.4000" targetFramework="net45" />
4-
<package id="Microsoft.AspNet.WebApi" version="5.2.2" targetFramework="net45" />
5-
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
6-
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
7-
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.2" targetFramework="net45" />
4+
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net45" />
5+
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
6+
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
7+
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
88
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net45" />
99
<package id="NHibernate" version="4.0.1.4000" targetFramework="net45" />
1010
<package id="System.Data.SQLite.Core" version="1.0.94.0" targetFramework="net45" />

Code/Sif3Framework/Sif.Framework.Tests/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
35+
[assembly: AssemblyVersion("1.1.0.0")]
36+
[assembly: AssemblyFileVersion("1.1.0.0")]

Code/Sif3Framework/Sif.Framework/Consumers/Consumer.cs

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,29 @@ public Consumer(string applicationKey, string instanceId = null, string userToke
109109
registrationService = new RegistrationService(SettingsManager.ConsumerSettings, SessionsManager.ConsumerSessionService);
110110
}
111111

112+
/// <summary>
113+
/// Build up a string of Matrix Parameters based upon the passed parameters.
114+
/// </summary>
115+
/// <param name="zone">Zone associated with a request.</param>
116+
/// <param name="context">Zone context.</param>
117+
/// <returns>String of Matrix Parameters.</returns>
118+
private string MatrixParameters(string zone = null, string context = null)
119+
{
120+
string matrixParameters = "";
121+
122+
if (!string.IsNullOrWhiteSpace(zone))
123+
{
124+
matrixParameters += ";zone=" + zone.Trim();
125+
}
126+
127+
if (!string.IsNullOrWhiteSpace(context))
128+
{
129+
matrixParameters += ";context=" + context.Trim();
130+
}
131+
132+
return matrixParameters;
133+
}
134+
112135
/// <summary>
113136
/// <see cref="IPayloadSerialisable{TSingle,TMultiple}.SerialiseSingle(TSingle)">SerialiseSingle</see>
114137
/// </summary>
@@ -158,17 +181,17 @@ public void Unregister(bool? deleteOnUnregister = null)
158181
}
159182

160183
/// <summary>
161-
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Create(TSingle)">Create</see>
184+
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Create(TSingle, string, string)">Create</see>
162185
/// </summary>
163-
public virtual TSingle Create(TSingle obj)
186+
public virtual TSingle Create(TSingle obj, string zone = null, string context = null)
164187
{
165188

166189
if (!RegistrationService.Registered)
167190
{
168191
throw new InvalidOperationException("Consumer has not registered.");
169192
}
170193

171-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + TypeName;
194+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + TypeName + MatrixParameters(zone, context);
172195
string body = SerialiseSingle(obj);
173196
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body);
174197
if (log.IsDebugEnabled) log.Debug("XML from POST request ...");
@@ -180,15 +203,15 @@ public virtual TSingle Create(TSingle obj)
180203
/// <summary>
181204
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Create(TMultiple)">Create</see>
182205
/// </summary>
183-
public virtual MultipleCreateResponse Create(TMultiple obj)
206+
public virtual MultipleCreateResponse Create(TMultiple obj, string zone = null, string context = null)
184207
{
185208

186209
if (!RegistrationService.Registered)
187210
{
188211
throw new InvalidOperationException("Consumer has not registered.");
189212
}
190213

191-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s";
214+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + MatrixParameters(zone, context);
192215
string body = SerialiseMultiple(obj);
193216
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body);
194217
if (log.IsDebugEnabled) log.Debug("XML from POST request ...");
@@ -200,9 +223,9 @@ public virtual MultipleCreateResponse Create(TMultiple obj)
200223
}
201224

202225
/// <summary>
203-
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Query(TPrimaryKey)">Query</see>
226+
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Query(TPrimaryKey, string, string)">Query</see>
204227
/// </summary>
205-
public virtual TSingle Query(TPrimaryKey refId)
228+
public virtual TSingle Query(TPrimaryKey refId, string zone = null, string context = null)
206229
{
207230

208231
if (!RegistrationService.Registered)
@@ -214,7 +237,7 @@ public virtual TSingle Query(TPrimaryKey refId)
214237

215238
try
216239
{
217-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + refId;
240+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + refId + MatrixParameters(zone, context);
218241
string xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken);
219242
if (log.IsDebugEnabled) log.Debug("XML from GET request ...");
220243
if (log.IsDebugEnabled) log.Debug(xml);
@@ -248,17 +271,17 @@ public virtual TSingle Query(TPrimaryKey refId)
248271
}
249272

250273
/// <summary>
251-
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Query(uint?, uint?)">Query</see>
274+
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Query(uint?, uint?, string, string)">Query</see>
252275
/// </summary>
253-
public virtual TMultiple Query(uint? navigationPage = null, uint? navigationPageSize = null)
276+
public virtual TMultiple Query(uint? navigationPage = null, uint? navigationPageSize = null, string zone = null, string context = null)
254277
{
255278

256279
if (!RegistrationService.Registered)
257280
{
258281
throw new InvalidOperationException("Consumer has not registered.");
259282
}
260283

261-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s";
284+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + MatrixParameters(zone, context);
262285
string xml;
263286

264287
if (navigationPage.HasValue && navigationPageSize.HasValue)
@@ -274,17 +297,17 @@ public virtual TMultiple Query(uint? navigationPage = null, uint? navigationPage
274297
}
275298

276299
/// <summary>
277-
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryByExample(TSingle, uint?, uint?)">Query</see>
300+
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryByExample(TSingle, uint?, uint?, string, string)">Query</see>
278301
/// </summary>
279-
public virtual TMultiple QueryByExample(TSingle obj, uint? navigationPage = null, uint? navigationPageSize = null)
302+
public virtual TMultiple QueryByExample(TSingle obj, uint? navigationPage = null, uint? navigationPageSize = null, string zone = null, string context = null)
280303
{
281304

282305
if (!RegistrationService.Registered)
283306
{
284307
throw new InvalidOperationException("Consumer has not registered.");
285308
}
286309

287-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s";
310+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + MatrixParameters(zone, context);
288311
string body = SerialiseSingle(obj);
289312
// TODO: Update PostRequest to accept paging parameters.
290313
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, "GET");
@@ -295,9 +318,9 @@ public virtual TMultiple QueryByExample(TSingle obj, uint? navigationPage = null
295318
}
296319

297320
/// <summary>
298-
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryByServicePath(IEnumerable{EqualCondition}, uint?, uint?)">Query</see>
321+
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.QueryByServicePath(IEnumerable{EqualCondition}, uint?, uint?, string, string)">Query</see>
299322
/// </summary>
300-
public virtual TMultiple QueryByServicePath(IEnumerable<EqualCondition> conditions, uint? navigationPage = null, uint? navigationPageSize = null)
323+
public virtual TMultiple QueryByServicePath(IEnumerable<EqualCondition> conditions, uint? navigationPage = null, uint? navigationPageSize = null, string zone = null, string context = null)
301324
{
302325

303326
if (!RegistrationService.Registered)
@@ -317,7 +340,7 @@ public virtual TMultiple QueryByServicePath(IEnumerable<EqualCondition> conditio
317340

318341
}
319342

320-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + servicePath + "/" + TypeName + "s";
343+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + servicePath + "/" + TypeName + "s" + MatrixParameters(zone, context);
321344
if (log.IsDebugEnabled) log.Debug("Service Path URL is " + url);
322345
string xml;
323346

@@ -334,35 +357,35 @@ public virtual TMultiple QueryByServicePath(IEnumerable<EqualCondition> conditio
334357
}
335358

336359
/// <summary>
337-
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Update(TSingle)">Update</see>
360+
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Update(TSingle, string, string)">Update</see>
338361
/// </summary>
339-
public virtual void Update(TSingle obj)
362+
public virtual void Update(TSingle obj, string zone = null, string context = null)
340363
{
341364

342365
if (!RegistrationService.Registered)
343366
{
344367
throw new InvalidOperationException("Consumer has not registered.");
345368
}
346369

347-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + obj.RefId;
370+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + obj.RefId + MatrixParameters(zone, context);
348371
string body = SerialiseSingle(obj);
349372
string xml = HttpUtils.PutRequest(url, RegistrationService.AuthorisationToken, body);
350373
if (log.IsDebugEnabled) log.Debug("XML from PUT request ...");
351374
if (log.IsDebugEnabled) log.Debug(xml);
352375
}
353376

354377
/// <summary>
355-
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKeyPK}.Update(TMultiple)">Update</see>
378+
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKeyPK}.Update(TMultiple, string, string)">Update</see>
356379
/// </summary>
357-
public virtual MultipleUpdateResponse Update(TMultiple obj)
380+
public virtual MultipleUpdateResponse Update(TMultiple obj, string zone = null, string context = null)
358381
{
359382

360383
if (!RegistrationService.Registered)
361384
{
362385
throw new InvalidOperationException("Consumer has not registered.");
363386
}
364387

365-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s";
388+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + MatrixParameters(zone, context);
366389
string body = SerialiseMultiple(obj);
367390
string xml = HttpUtils.PutRequest(url, RegistrationService.AuthorisationToken, body);
368391
if (log.IsDebugEnabled) log.Debug("XML from PUT request ...");
@@ -374,26 +397,26 @@ public virtual MultipleUpdateResponse Update(TMultiple obj)
374397
}
375398

376399
/// <summary>
377-
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Delete(TPrimaryKey)">Delete</see>
400+
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Delete(TPrimaryKey, string, string)">Delete</see>
378401
/// </summary>
379-
public virtual void Delete(TPrimaryKey refId)
402+
public virtual void Delete(TPrimaryKey refId, string zone = null, string context = null)
380403
{
381404

382405
if (!RegistrationService.Registered)
383406
{
384407
throw new InvalidOperationException("Consumer has not registered.");
385408
}
386409

387-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + refId;
410+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + refId + MatrixParameters(zone, context);
388411
string xml = HttpUtils.DeleteRequest(url, RegistrationService.AuthorisationToken);
389412
if (log.IsDebugEnabled) log.Debug("XML from DELETE request ...");
390413
if (log.IsDebugEnabled) log.Debug(xml);
391414
}
392415

393416
/// <summary>
394-
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Delete(IEnumerable{TPrimaryKey})">Delete</see>
417+
/// <see cref="IConsumer{TSingle,TMultiple,TPrimaryKey}.Delete(IEnumerable{TPrimaryKey}, string, string)">Delete</see>
395418
/// </summary>
396-
public virtual MultipleDeleteResponse Delete(IEnumerable<TPrimaryKey> refIds)
419+
public virtual MultipleDeleteResponse Delete(IEnumerable<TPrimaryKey> refIds, string zone = null, string context = null)
397420
{
398421

399422
if (!RegistrationService.Registered)
@@ -410,7 +433,7 @@ public virtual MultipleDeleteResponse Delete(IEnumerable<TPrimaryKey> refIds)
410433
}
411434

412435
deleteRequestType request = new deleteRequestType { deletes = deleteIds.ToArray() };
413-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s";
436+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + MatrixParameters(zone, context);
414437
string body = SerialiserFactory.GetXmlSerialiser<deleteRequestType>().Serialise(request);
415438
string xml = HttpUtils.PutRequest(url, RegistrationService.AuthorisationToken, body, "DELETE");
416439
if (log.IsDebugEnabled) log.Debug("XML from PUT (DELETE) request ...");

0 commit comments

Comments
 (0)