Skip to content

Commit

Permalink
Merge pull request #23 from dynamicweb/mss/16576-ODataProvider-FailJo…
Browse files Browse the repository at this point in the history
…b&Typo

changed typo from Recieved to Received, and changed some logger.warn …
  • Loading branch information
frederik5480 authored Nov 24, 2023
2 parents 103c531 + 6fa318f commit c004701
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.0.11</Version>
<Version>10.0.12</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>OData Provider</Title>
<Description>The Odata Provider lets you fetch and map data from or to any OData endpoint.</Description>
Expand Down
4 changes: 3 additions & 1 deletion src/ODataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Dynamicweb.DataIntegration.Providers.ODataProvider.Model;
using Dynamicweb.Extensibility.AddIns;
using Dynamicweb.Extensibility.Editors;
using Dynamicweb.Logging;
using Dynamicweb.Security.Licensing;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -688,7 +689,8 @@ public override bool RunJob(Job job)
catch (Exception e)
{
Logger?.Log(e.ToString());
throw;
LogManager.System.GetLogger(LogCategory.Application, "Dataintegration").Error($"{GetType().Name} error: {e.Message} Stack: {e.StackTrace}", e);
return false;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ODataSourceReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ private List<string> GetSelectAsParameters()
}
else
{
_logger?.Info("Detected many active column mappings, so will not auto add $select with all active column mappings and by that limit the data recieved from Endpoint.");
_logger?.Info("Detected many active column mappings, so will not auto add $select with all active column mappings and by that limit the data received from Endpoint.");
}
}
return result;
Expand Down
19 changes: 8 additions & 11 deletions src/ODataWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,8 @@ public void Write(Dictionary<string, object> Row)
var responseFromEndpoint = GetFromEndpoint<JsonObject>(url, null);
if (!string.IsNullOrEmpty(responseFromEndpoint?.Result?.Error))
{
if (responseFromEndpoint.Result.Status == HttpStatusCode.Unauthorized)
{
throw new Exception(responseFromEndpoint.Result.Error);
}
Logger?.Warn($"Error Url: {url}. Response Error: {responseFromEndpoint.Result.Error}. Status response code: {responseFromEndpoint.Result.Status}");
return;
Logger?.Error($"Error Url: {url}. Response Error: {responseFromEndpoint.Result.Error}. Status response code: {responseFromEndpoint.Result.Status}");
throw new Exception(responseFromEndpoint.Result.Error);
}

var response = responseFromEndpoint?.Result?.Content?.Value;
Expand All @@ -86,7 +82,7 @@ public void Write(Dictionary<string, object> Row)
}

var jsonObject = response[0];
Logger?.Info($"Recieved response from Endpoint = {jsonObject.ToJsonString()}");
Logger?.Info($"Received response from Endpoint = {jsonObject.ToJsonString()}");

var patchJson = MapValuesToJSon(columnMappings, Row, true);
if (patchJson.Equals(new JsonObject().ToString()))
Expand Down Expand Up @@ -139,22 +135,23 @@ public void Write(Dictionary<string, object> Row)
awaitResponseFromEndpoint.Wait();
if (!string.IsNullOrEmpty(awaitResponseFromEndpoint?.Result?.Error))
{
Logger?.Warn($"Error Url: {url}. Response Error: {awaitResponseFromEndpoint.Result.Error}. Status response code: {awaitResponseFromEndpoint.Result.Status}");
Logger?.Error($"Error Url: {url}. Response Error: {awaitResponseFromEndpoint.Result.Error}. Status response code: {awaitResponseFromEndpoint.Result.Status}");
throw new Exception(awaitResponseFromEndpoint.Result.Error);
}

PostBackObject = awaitResponseFromEndpoint?.Result?.Content;

if (awaitResponseFromEndpoint?.Result?.Status != HttpStatusCode.NoContent)
{
Logger?.Info($"Recieved response from Endpoint = {PostBackObject?.ToJsonString()}");
Logger?.Info($"Received response from Endpoint = {PostBackObject?.ToJsonString()}");
}
else if (_responseMappings.Any())
{
Logger?.Info($"Endpoint returned no content so can not do response mappings on this record.");
}
else
{
Logger?.Info($"Recieved no response from Endpoint");
Logger?.Info($"Received no response from Endpoint");
}
}

Expand Down Expand Up @@ -281,7 +278,7 @@ internal string MapValuesToJSon(ColumnMappingCollection columnMappings, Dictiona
}
}
}
return jsonObject.ToString();
return jsonObject.ToJsonString();
}

public static string GetTheDateTimeInZeroTimeZone(object dateTimeObject, bool isEdmDate)
Expand Down

0 comments on commit c004701

Please sign in to comment.