Skip to content

Commit

Permalink
Ensure that the serviceType header is set to FUNCTIONAL for Functiona…
Browse files Browse the repository at this point in the history
…l Service calls.
  • Loading branch information
rafidzal committed Apr 11, 2017
1 parent b76e9a1 commit 462c5a0
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 103 deletions.
8 changes: 4 additions & 4 deletions Code/Sif3Framework/Sif.Framework/Consumers/Consumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public virtual TMultiple Query(uint? navigationPage = null, uint? navigationPage

if (navigationPage.HasValue && navigationPageSize.HasValue)
{
xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken, (int)navigationPage, (int)navigationPageSize);
xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken, navigationPage: (int)navigationPage, navigationPageSize: (int)navigationPageSize);
}
else
{
Expand All @@ -305,7 +305,7 @@ public virtual TMultiple QueryByExample(TSingle obj, uint? navigationPage = null
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + HttpUtils.MatrixParameters(zoneId, contextId);
string body = SerialiseSingle(obj);
// TODO: Update PostRequest to accept paging parameters.
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, "GET");
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, methodOverride: "GET");
if (log.IsDebugEnabled) log.Debug("XML from POST (Query by Example) request ...");
if (log.IsDebugEnabled) log.Debug(xml);

Expand Down Expand Up @@ -341,7 +341,7 @@ public virtual TMultiple QueryByServicePath(IEnumerable<EqualCondition> conditio

if (navigationPage.HasValue && navigationPageSize.HasValue)
{
xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken, (int)navigationPage, (int)navigationPageSize);
xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken, navigationPage: (int)navigationPage, navigationPageSize: (int)navigationPageSize);
}
else
{
Expand Down Expand Up @@ -460,7 +460,7 @@ public virtual MultipleDeleteResponse Delete(IEnumerable<TPrimaryKey> refIds, st
deleteRequestType request = new deleteRequestType { deletes = deleteIds.ToArray() };
string url = EnvironmentUtils.ParseServiceUrl(EnvironmentTemplate) + "/" + TypeName + "s" + HttpUtils.MatrixParameters(zoneId, contextId);
string body = SerialiserFactory.GetXmlSerialiser<deleteRequestType>().Serialise(request);
string xml = HttpUtils.PutRequest(url, RegistrationService.AuthorisationToken, body, "DELETE");
string xml = HttpUtils.PutRequest(url, RegistrationService.AuthorisationToken, body, methodOverride: "DELETE");
if (log.IsDebugEnabled) log.Debug("XML from PUT (DELETE) request ...");
if (log.IsDebugEnabled) log.Debug(xml);
deleteResponseType updateResponseType = SerialiserFactory.GetXmlSerialiser<deleteResponseType>().Deserialise(xml);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public virtual Job Create(Job job, string zoneId = null, string contextId = null

string url = GetURLPrefix(job.Name) + "/" + job.Name + HttpUtils.MatrixParameters(zoneId, contextId);
string body = SerialiseSingle<Job, jobType>(job);
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body);
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, ServiceType.FUNCTIONAL);
if (log.IsDebugEnabled) log.Debug("XML from POST request ...");
if (log.IsDebugEnabled) log.Debug(xml);

Expand All @@ -205,7 +205,7 @@ public virtual MultipleCreateResponse Create(List<Job> jobs, string zoneId = nul

string url = GetURLPrefix(jobName) + HttpUtils.MatrixParameters(zoneId, contextId);
string body = SerialiseMultiple(jobs);
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body);
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, ServiceType.FUNCTIONAL);
if (log.IsDebugEnabled) log.Debug("XML from POST request ...");
if (log.IsDebugEnabled) log.Debug(xml);
createResponseType createResponseType = SerialiserFactory.GetXmlSerialiser<createResponseType>().Deserialise(xml);
Expand Down Expand Up @@ -240,7 +240,7 @@ where s.StatusCode.StartsWith("2")

foreach(Job job in toFetch)
{
fetched.Add(this.Query(job, zoneId, contextId));
fetched.Add(Query(job, zoneId, contextId));
}

return fetched;
Expand All @@ -262,7 +262,7 @@ public virtual Job Query(Job job, string zoneId = null, string contextId = null)
try
{
string url = GetURLPrefix(job.Name) + "/" + job.Id + HttpUtils.MatrixParameters(zoneId, contextId);
string xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken);
string xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken, ServiceType.FUNCTIONAL);
if (log.IsDebugEnabled) log.Debug("XML from GET request ...");
if (log.IsDebugEnabled) log.Debug(xml);
return DeserialiseSingle<Job, jobType>(xml);
Expand Down Expand Up @@ -310,11 +310,11 @@ public virtual List<Job> Query(string jobName, uint? navigationPage = null, uint

if (navigationPage.HasValue && navigationPageSize.HasValue)
{
xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken, (int)navigationPage, (int)navigationPageSize);
xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken, ServiceType.FUNCTIONAL, (int)navigationPage, (int)navigationPageSize);
}
else
{
xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken);
xml = HttpUtils.GetRequest(url, RegistrationService.AuthorisationToken, ServiceType.FUNCTIONAL);
}

return DeserialiseMultiple<Job, jobType>(xml);
Expand All @@ -338,7 +338,7 @@ public virtual List<Job> QueryByExample(Job job, uint? navigationPage = null, ui
string url = GetURLPrefix(job.Name) + HttpUtils.MatrixParameters(zoneId, contextId);
string body = SerialiseSingle<Job, jobType>(job);
// TODO: Update PostRequest to accept paging parameters.
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, "GET");
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, ServiceType.FUNCTIONAL, "GET");
if (log.IsDebugEnabled) log.Debug("XML from POST (Query by Example) request ...");
if (log.IsDebugEnabled) log.Debug(xml);

Expand Down Expand Up @@ -389,7 +389,7 @@ public virtual void Delete(Job job, string zoneId = null, string contextId = nul
checkJob(job, RightType.DELETE, zoneId);

string url = GetURLPrefix(job.Name) + "/" + job.Id + HttpUtils.MatrixParameters(zoneId, contextId);
string xml = HttpUtils.DeleteRequest(url, RegistrationService.AuthorisationToken);
string xml = HttpUtils.DeleteRequest(url, RegistrationService.AuthorisationToken, ServiceType.FUNCTIONAL);
if (log.IsDebugEnabled) log.Debug("XML from DELETE request ...");
if (log.IsDebugEnabled) log.Debug(xml);
}
Expand Down Expand Up @@ -417,7 +417,7 @@ public virtual MultipleDeleteResponse Delete(List<Job> jobs, string zoneId = nul
deleteRequestType request = new deleteRequestType { deletes = deleteIds.ToArray() };
string url = GetURLPrefix(jobName) + HttpUtils.MatrixParameters(zoneId, contextId);
string body = SerialiserFactory.GetXmlSerialiser<deleteRequestType>().Serialise(request);
string xml = HttpUtils.PutRequest(url, RegistrationService.AuthorisationToken, body, "DELETE");
string xml = HttpUtils.PutRequest(url, RegistrationService.AuthorisationToken, body, ServiceType.FUNCTIONAL, "DELETE");
if (log.IsDebugEnabled) log.Debug("XML from PUT (DELETE) request ...");
if (log.IsDebugEnabled) log.Debug(xml);
deleteResponseType updateResponseType = SerialiserFactory.GetXmlSerialiser<deleteResponseType>().Deserialise(xml);
Expand Down Expand Up @@ -445,7 +445,7 @@ public virtual string CreateToPhase(Job job, string phaseName, string body = nul

string response = null;
string url = GetURLPrefix(job.Name) + "/" + job.Id + "/" + phaseName + HttpUtils.MatrixParameters(zoneId, contextId);
response = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, contentTypeOverride: contentTypeOverride, acceptOverride: acceptOverride);
response = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, ServiceType.FUNCTIONAL, contentTypeOverride: contentTypeOverride, acceptOverride: acceptOverride);
if (log.IsDebugEnabled) log.Debug("String from CREATE request to phase ...");
if (log.IsDebugEnabled) log.Debug(response);
return response;
Expand All @@ -470,7 +470,7 @@ public virtual string RetrieveToPhase(Job job, string phaseName, string body = n

string response = null;
string url = GetURLPrefix(job.Name) + "/" + job.Id + "/" + phaseName + HttpUtils.MatrixParameters(zoneId, contextId);
response = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, "GET", contentTypeOverride, acceptOverride);
response = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, ServiceType.FUNCTIONAL, "GET", contentTypeOverride, acceptOverride);
if (log.IsDebugEnabled) log.Debug("String from GET request to phase ...");
if (log.IsDebugEnabled) log.Debug(response);
return response;
Expand All @@ -495,7 +495,7 @@ public virtual string UpdateToPhase(Job job, string phaseName, string body, stri

string response = null;
string url = GetURLPrefix(job.Name) + "/" + job.Id + "/" + phaseName + HttpUtils.MatrixParameters(zoneId, contextId);
response = HttpUtils.PutRequest(url, RegistrationService.AuthorisationToken, body, contentTypeOverride: contentTypeOverride, acceptOverride: acceptOverride);
response = HttpUtils.PutRequest(url, RegistrationService.AuthorisationToken, body, ServiceType.FUNCTIONAL, contentTypeOverride: contentTypeOverride, acceptOverride: acceptOverride);
if (log.IsDebugEnabled) log.Debug("String from PUT request to phase ...");
if (log.IsDebugEnabled) log.Debug(response);
return response;
Expand All @@ -520,7 +520,7 @@ public virtual string DeleteToPhase(Job job, string phaseName, string body, stri

string response = null;
string url = GetURLPrefix(job.Name) + "/" + job.Id + "/" + phaseName + HttpUtils.MatrixParameters(zoneId, contextId);
response = HttpUtils.DeleteRequest(url, RegistrationService.AuthorisationToken, body, contentTypeOverride: contentTypeOverride, acceptOverride: acceptOverride);
response = HttpUtils.DeleteRequest(url, RegistrationService.AuthorisationToken, body, ServiceType.FUNCTIONAL, contentTypeOverride, acceptOverride);
if (log.IsDebugEnabled) log.Debug("String from DELETE request to phase ...");
if (log.IsDebugEnabled) log.Debug(response);
return response;
Expand All @@ -543,7 +543,7 @@ public virtual PhaseState CreateToState(Job job, string phaseName, PhaseState it

string url = GetURLPrefix(job.Name) + "/" + job.Id + "/" + phaseName + "/states/state" + HttpUtils.MatrixParameters(zoneId, contextId);
string body = SerialiseSingle<PhaseState, stateType>(item);
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body);
string xml = HttpUtils.PostRequest(url, RegistrationService.AuthorisationToken, body, ServiceType.FUNCTIONAL);
if (log.IsDebugEnabled) log.Debug("Guid from CREATE request to state on phase ...");
if (log.IsDebugEnabled) log.Debug(xml);
return DeserialiseSingle<PhaseState, stateType>(xml);
Expand Down
Loading

0 comments on commit 462c5a0

Please sign in to comment.