Skip to content

Commit

Permalink
Update references to zone and context to zoneId and contextId for all…
Browse files Browse the repository at this point in the history
… service layer code.
  • Loading branch information
rafidzal committed Mar 31, 2017
1 parent 4d97478 commit b76e9a1
Show file tree
Hide file tree
Showing 16 changed files with 307 additions and 147 deletions.
6 changes: 3 additions & 3 deletions Code/Sif3Framework/Sif.Framework/Providers/BasicProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public override IHttpActionResult Post(List<T> objs, [MatrixParameter] string[]

if (mustUseAdvisory.HasValue && mustUseAdvisory.Value == true)
{
status.id = service.Create(obj, mustUseAdvisory, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0])).RefId;
status.id = service.Create(obj, mustUseAdvisory, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0])).RefId;
status.statusCode = ((int)HttpStatusCode.Created).ToString();
}
else
Expand All @@ -106,7 +106,7 @@ public override IHttpActionResult Post(List<T> objs, [MatrixParameter] string[]
}
else
{
status.id = service.Create(obj, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0])).RefId;
status.id = service.Create(obj, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0])).RefId;
status.statusCode = ((int)HttpStatusCode.Created).ToString();
}

Expand Down Expand Up @@ -185,7 +185,7 @@ public override IHttpActionResult Put(List<T> objs, [MatrixParameter] string[] z

try
{
service.Update(obj, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
service.Update(obj, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));
status.statusCode = ((int)HttpStatusCode.NoContent).ToString();
}
catch (ArgumentException e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@ public virtual HttpResponseMessage Post([FromUri] string serviceName, [FromUri]
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Request requires use of advisory id, but none has been supplied.");
}

Guid id = service.Create(item, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
Guid id = service.Create(item, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));

if (SettingsManager.ProviderSettings.JobBinding)
{
service.Bind(id, getOwnerId(sessionToken));
}

jobType job = service.Retrieve(id, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
jobType job = service.Retrieve(id, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));

string uri = Url.Link("ServicesRoute", new { controller = serviceName, id = id });

Expand Down Expand Up @@ -168,7 +168,7 @@ public virtual HttpResponseMessage Post([FromUri] string serviceName, [FromBody]
{
throw new ArgumentException("Service " + serviceName + " does not handle jobs named " + job.name);
}
Guid id = service.Create(job, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
Guid id = service.Create(job, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));

if (SettingsManager.ProviderSettings.JobBinding)
{
Expand Down Expand Up @@ -243,7 +243,7 @@ public virtual ICollection<jobType> Get([FromUri] string serviceName, [MatrixPar
try
{
IFunctionalService service = getService(serviceName);
ICollection<jobType> jobs = service.Retrieve(zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
ICollection<jobType> jobs = service.Retrieve(zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));
foreach (jobType job in jobs)
{
if (!SettingsManager.ProviderSettings.JobBinding
Expand Down Expand Up @@ -283,7 +283,7 @@ public virtual HttpResponseMessage Get([FromUri] string serviceName, [FromUri] G
try
{
IFunctionalService service = getService(serviceName);
item = service.Retrieve(id, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
item = service.Retrieve(id, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));

if (SettingsManager.ProviderSettings.JobBinding
&& !service.IsBound(Guid.Parse(item.id), getOwnerId(sessionToken)))
Expand Down Expand Up @@ -351,7 +351,7 @@ public virtual HttpResponseMessage Delete([FromUri] string serviceName, [FromUri
throw new InvalidSessionException("Request failed as one or more jobs referred to in this request do not belong to this consumer.");
}

service.Delete(id, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
service.Delete(id, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));

if (SettingsManager.ProviderSettings.JobBinding)
{
Expand Down Expand Up @@ -391,7 +391,7 @@ public virtual HttpResponseMessage Delete([FromUri] string serviceName, [FromBod
throw new InvalidSessionException("Request failed as job does not belong to this consumer.");
}

service.Delete(Guid.Parse(deleteId.id), zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
service.Delete(Guid.Parse(deleteId.id), zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));

if (SettingsManager.ProviderSettings.JobBinding)
{
Expand Down Expand Up @@ -450,7 +450,7 @@ public virtual HttpResponseMessage Post([FromUri] string serviceName, [FromUri]
{
throw new InvalidSessionException("Request failed as the job referred to in this request does not belong to this consumer.");
}
return OKResult(service.CreateToPhase(id, phaseName, body, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]), contentType: HttpUtils.GetContentType(Request), accept: HttpUtils.GetAccept(Request)));
return OKResult(service.CreateToPhase(id, phaseName, body, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]), contentType: HttpUtils.GetContentType(Request), accept: HttpUtils.GetAccept(Request)));
}
catch (ArgumentException e)
{
Expand Down Expand Up @@ -491,7 +491,7 @@ public virtual HttpResponseMessage Get([FromUri] string serviceName, [FromUri] G
{
throw new InvalidSessionException("Request failed as the job referred to in this request does not belong to this consumer.");
}
return OKResult(service.RetrieveToPhase(id, phaseName, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]), contentType: HttpUtils.GetContentType(Request), accept: HttpUtils.GetAccept(Request)));
return OKResult(service.RetrieveToPhase(id, phaseName, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]), contentType: HttpUtils.GetContentType(Request), accept: HttpUtils.GetAccept(Request)));
}
catch (ArgumentException e)
{
Expand Down Expand Up @@ -530,7 +530,7 @@ public virtual HttpResponseMessage Put([FromUri] string serviceName, [FromUri] G
{
throw new InvalidSessionException("Request failed as the job referred to in this request does not belong to this consumer.");
}
return OKResult(service.UpdateToPhase(id, phaseName, body, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]), contentType: HttpUtils.GetContentType(Request), accept: HttpUtils.GetAccept(Request)));
return OKResult(service.UpdateToPhase(id, phaseName, body, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]), contentType: HttpUtils.GetContentType(Request), accept: HttpUtils.GetAccept(Request)));
}
catch (ArgumentException e)
{
Expand Down Expand Up @@ -571,7 +571,7 @@ public virtual HttpResponseMessage Delete([FromUri] string serviceName, [FromUri
{
throw new InvalidSessionException("Request failed as the job referred to in this request does not belong to this consumer.");
}
return OKResult(service.DeleteToPhase(id, phaseName, body, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]), contentType: HttpUtils.GetContentType(Request), accept: HttpUtils.GetAccept(Request)));
return OKResult(service.DeleteToPhase(id, phaseName, body, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]), contentType: HttpUtils.GetContentType(Request), accept: HttpUtils.GetAccept(Request)));
}
catch (ArgumentException e)
{
Expand Down Expand Up @@ -615,7 +615,7 @@ public virtual HttpResponseMessage Post([FromUri] string serviceName, [FromUri]
{
throw new InvalidSessionException("Request failed as the job referred to in this request does not belong to this consumer.");
}
stateType state = service.CreateToState(id, phaseName, item, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
stateType state = service.CreateToState(id, phaseName, item, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));

string uri = Url.Link("ServiceStatesRoute", new { controller = serviceName, id = id, phaseName = phaseName, stateId = state.id });
result = Request.CreateResponse<stateType>(HttpStatusCode.Created, state);
Expand Down
18 changes: 9 additions & 9 deletions Code/Sif3Framework/Sif.Framework/Providers/Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public virtual IHttpActionResult Post(TSingle obj, [MatrixParameter] string[] zo

if (mustUseAdvisory.HasValue && mustUseAdvisory.Value == true)
{
TSingle createdObject = service.Create(obj, mustUseAdvisory, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
TSingle createdObject = service.Create(obj, mustUseAdvisory, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));
string uri = Url.Link("DefaultApi", new { controller = typeof(TSingle).Name, id = createdObject.RefId });
result = Created(uri, createdObject);
}
Expand All @@ -132,7 +132,7 @@ public virtual IHttpActionResult Post(TSingle obj, [MatrixParameter] string[] zo
}
else
{
TSingle createdObject = service.Create(obj, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
TSingle createdObject = service.Create(obj, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));
string uri = Url.Link("DefaultApi", new { controller = typeof(TSingle).Name, id = createdObject.RefId });
result = Created(uri, createdObject);
}
Expand Down Expand Up @@ -188,7 +188,7 @@ public virtual IHttpActionResult Post(TMultiple obj, [MatrixParameter] string[]

bool? mustUseAdvisory = HttpUtils.GetMustUseAdvisory(Request.Headers);
MultipleCreateResponse multipleCreateResponse =
((IProviderService<TSingle, TMultiple>)service).Create(obj, mustUseAdvisory, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
((IProviderService<TSingle, TMultiple>)service).Create(obj, mustUseAdvisory, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));
createResponseType createResponse = MapperFactory.CreateInstance<MultipleCreateResponse, createResponseType>(multipleCreateResponse);
IHttpActionResult result = Ok(createResponse);

Expand Down Expand Up @@ -222,7 +222,7 @@ public virtual IHttpActionResult Get([FromUri(Name = "id")] string refId, [Matri

try
{
TSingle obj = service.Retrieve(refId, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
TSingle obj = service.Retrieve(refId, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));

if (obj == null)
{
Expand Down Expand Up @@ -508,7 +508,7 @@ public virtual IHttpActionResult Get(string object1,

}

TMultiple objs = service.Retrieve(conditions, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
TMultiple objs = service.Retrieve(conditions, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));

if (objs == null)
{
Expand Down Expand Up @@ -567,7 +567,7 @@ public virtual IHttpActionResult Put([FromUri(Name = "id")] string refId, TSingl

try
{
service.Update(obj, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
service.Update(obj, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));
result = StatusCode(HttpStatusCode.NoContent);
}
catch (ArgumentException e)
Expand Down Expand Up @@ -609,7 +609,7 @@ public virtual IHttpActionResult Put(TMultiple obj, [MatrixParameter] string[] z
}

MultipleUpdateResponse multipleUpdateResponse =
((IProviderService<TSingle, TMultiple>)service).Update(obj, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
((IProviderService<TSingle, TMultiple>)service).Update(obj, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));
updateResponseType updateResponse = MapperFactory.CreateInstance<MultipleUpdateResponse, updateResponseType>(multipleUpdateResponse);
IHttpActionResult result = Ok(updateResponse);

Expand Down Expand Up @@ -638,7 +638,7 @@ public virtual IHttpActionResult Delete([FromUri(Name = "id")] string refId, [Ma

try
{
service.Delete(refId, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
service.Delete(refId, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));
result = StatusCode(HttpStatusCode.NoContent);
}
catch (ArgumentException e)
Expand Down Expand Up @@ -692,7 +692,7 @@ public virtual IHttpActionResult Delete(deleteRequestType deleteRequest, [Matrix

try
{
service.Delete(deleteId.id, zone: (zoneId == null ? null : zoneId[0]), context: (contextId == null ? null : contextId[0]));
service.Delete(deleteId.id, zoneId: (zoneId == null ? null : zoneId[0]), contextId: (contextId == null ? null : contextId[0]));
status.statusCode = ((int)HttpStatusCode.NoContent).ToString();
}
catch (ArgumentException e)
Expand Down
Loading

0 comments on commit b76e9a1

Please sign in to comment.