Skip to content

Commit 8b95d14

Browse files
committed
Update the Funtional Service Provider to use the correct matrix parameters.
1 parent 684394e commit 8b95d14

5 files changed

Lines changed: 61 additions & 84 deletions

File tree

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

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

113-
/// <summary>
114-
/// Build up a string of Matrix Parameters based upon the passed parameters.
115-
/// </summary>
116-
/// <param name="zone">Zone associated with a request.</param>
117-
/// <param name="context">Zone context.</param>
118-
/// <returns>String of Matrix Parameters.</returns>
119-
private string MatrixParameters(string zone = null, string context = null)
120-
{
121-
string matrixParameters = "";
122-
123-
if (!string.IsNullOrWhiteSpace(zone))
124-
{
125-
matrixParameters += ";zoneId=" + zone.Trim();
126-
}
127-
128-
if (!string.IsNullOrWhiteSpace(context))
129-
{
130-
matrixParameters += ";contextId=" + context.Trim();
131-
}
132-
133-
return matrixParameters;
134-
}
135-
136113
/// <summary>
137114
/// <see cref="IPayloadSerialisable{TSingle,TMultiple}.SerialiseSingle(TSingle)">SerialiseSingle</see>
138115
/// </summary>
@@ -192,7 +169,7 @@ public string GetChangesSinceMarker(string zone = null, string context = null)
192169
throw new InvalidOperationException("Consumer has not registered.");
193170
}
194171

195-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + MatrixParameters(zone, context);
172+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + HttpUtils.MatrixParameters(zone, context);
196173
WebHeaderCollection responseHeaders = HttpUtils.HeadRequest(url, RegistrationService.AuthorisationToken);
197174

198175
return responseHeaders[HttpUtils.RequestHeader.changesSinceMarker.ToDescription()];
@@ -209,7 +186,7 @@ public virtual TSingle Create(TSingle obj, string zone = null, string context =
209186
throw new InvalidOperationException("Consumer has not registered.");
210187
}
211188

212-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + TypeName + MatrixParameters(zone, context);
189+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + TypeName + HttpUtils.MatrixParameters(zone, context);
213190
string body = SerialiseSingle(obj);
214191
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body);
215192
if (log.IsDebugEnabled) log.Debug("XML from POST request ...");
@@ -229,7 +206,7 @@ public virtual MultipleCreateResponse Create(TMultiple obj, string zone = null,
229206
throw new InvalidOperationException("Consumer has not registered.");
230207
}
231208

232-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + MatrixParameters(zone, context);
209+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + HttpUtils.MatrixParameters(zone, context);
233210
string body = SerialiseMultiple(obj);
234211
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body);
235212
if (log.IsDebugEnabled) log.Debug("XML from POST request ...");
@@ -255,7 +232,7 @@ public virtual TSingle Query(TPrimaryKey refId, string zone = null, string conte
255232

256233
try
257234
{
258-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + refId + MatrixParameters(zone, context);
235+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + refId + HttpUtils.MatrixParameters(zone, context);
259236
string xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken);
260237
if (log.IsDebugEnabled) log.Debug("XML from GET request ...");
261238
if (log.IsDebugEnabled) log.Debug(xml);
@@ -299,7 +276,7 @@ public virtual TMultiple Query(uint? navigationPage = null, uint? navigationPage
299276
throw new InvalidOperationException("Consumer has not registered.");
300277
}
301278

302-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + MatrixParameters(zone, context);
279+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + HttpUtils.MatrixParameters(zone, context);
303280
string xml;
304281

305282
if (navigationPage.HasValue && navigationPageSize.HasValue)
@@ -325,7 +302,7 @@ public virtual TMultiple QueryByExample(TSingle obj, uint? navigationPage = null
325302
throw new InvalidOperationException("Consumer has not registered.");
326303
}
327304

328-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + MatrixParameters(zone, context);
305+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + HttpUtils.MatrixParameters(zone, context);
329306
string body = SerialiseSingle(obj);
330307
// TODO: Update PostRequest to accept paging parameters.
331308
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, "GET");
@@ -358,7 +335,7 @@ public virtual TMultiple QueryByServicePath(IEnumerable<EqualCondition> conditio
358335

359336
}
360337

361-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + servicePath + "/" + TypeName + "s" + MatrixParameters(zone, context);
338+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + servicePath + "/" + TypeName + "s" + HttpUtils.MatrixParameters(zone, context);
362339
if (log.IsDebugEnabled) log.Debug("Service Path URL is " + url);
363340
string xml;
364341

@@ -386,7 +363,7 @@ public TMultiple QueryChangesSince(string changesSinceMarker, out string nextCha
386363
}
387364

388365
string changesSinceParameter = (changesSinceMarker == null ? string.Empty : "?changesSinceMarker=" + changesSinceMarker);
389-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + MatrixParameters(zone, context) + changesSinceParameter;
366+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + HttpUtils.MatrixParameters(zone, context) + changesSinceParameter;
390367
WebHeaderCollection responseHeaders;
391368
string xml;
392369

@@ -415,7 +392,7 @@ public virtual void Update(TSingle obj, string zone = null, string context = nul
415392
throw new InvalidOperationException("Consumer has not registered.");
416393
}
417394

418-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + obj.RefId + MatrixParameters(zone, context);
395+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + obj.RefId + HttpUtils.MatrixParameters(zone, context);
419396
string body = SerialiseSingle(obj);
420397
string xml = HttpUtils.PutRequest(url, RegistrationService.AuthorisationToken, body);
421398
if (log.IsDebugEnabled) log.Debug("XML from PUT request ...");
@@ -433,7 +410,7 @@ public virtual MultipleUpdateResponse Update(TMultiple obj, string zone = null,
433410
throw new InvalidOperationException("Consumer has not registered.");
434411
}
435412

436-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + MatrixParameters(zone, context);
413+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + HttpUtils.MatrixParameters(zone, context);
437414
string body = SerialiseMultiple(obj);
438415
string xml = HttpUtils.PutRequest(url, RegistrationService.AuthorisationToken, body);
439416
if (log.IsDebugEnabled) log.Debug("XML from PUT request ...");
@@ -455,7 +432,7 @@ public virtual void Delete(TPrimaryKey refId, string zone = null, string context
455432
throw new InvalidOperationException("Consumer has not registered.");
456433
}
457434

458-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + refId + MatrixParameters(zone, context);
435+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + "/" + refId + HttpUtils.MatrixParameters(zone, context);
459436
string xml = HttpUtils.DeleteRequest(url, RegistrationService.AuthorisationToken);
460437
if (log.IsDebugEnabled) log.Debug("XML from DELETE request ...");
461438
if (log.IsDebugEnabled) log.Debug(xml);
@@ -481,7 +458,7 @@ public virtual MultipleDeleteResponse Delete(IEnumerable<TPrimaryKey> refIds, st
481458
}
482459

483460
deleteRequestType request = new deleteRequestType { deletes = deleteIds.ToArray() };
484-
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + MatrixParameters(zone, context);
461+
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + HttpUtils.MatrixParameters(zone, context);
485462
string body = SerialiserFactory.GetXmlSerialiser<deleteRequestType>().Serialise(request);
486463
string xml = HttpUtils.PutRequest(url, RegistrationService.AuthorisationToken, body, "DELETE");
487464
if (log.IsDebugEnabled) log.Debug("XML from PUT (DELETE) request ...");

0 commit comments

Comments
 (0)