Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.8.4</Version>
<Version>10.8.5</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
86 changes: 44 additions & 42 deletions src/ODataProvider.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using Dynamicweb.Core;
using Dynamicweb.Core;
using Dynamicweb.DataIntegration.EndpointManagement;
using Dynamicweb.DataIntegration.Integration;
using Dynamicweb.DataIntegration.Integration.ERPIntegration;
Expand All @@ -20,6 +9,17 @@
using Dynamicweb.Extensibility.Editors;
using Dynamicweb.Logging;
using Dynamicweb.Security.Licensing;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;

namespace Dynamicweb.DataIntegration.Providers.ODataProvider;

Expand All @@ -31,7 +31,7 @@ namespace Dynamicweb.DataIntegration.Providers.ODataProvider;
[ResponseMapping(true)]
public class ODataProvider : BaseProvider, ISource, IDestination, IParameterOptions, IODataBaseProvider, IParameterVisibility
{
internal readonly EndpointService _endpointService = new();
internal readonly EndpointService _endpointService = new();
internal readonly EndpointCollectionService _endpointCollectionService = new EndpointCollectionService();
internal Schema _schema;
internal Endpoint _endpoint;
Expand Down Expand Up @@ -219,20 +219,20 @@ IEnumerable<ParameterOption> IParameterOptions.GetParameterOptions(string parame
{
var result = new List<ParameterOption>();

foreach(var collection in _endpointCollectionService.GetEndpointCollections().OrderBy(ec => ec.Sorting))
{
var parameterOptions = _endpointCollectionService.GetEndpoints(collection.Id).Select(endpoint =>
new ParameterOption(endpoint.Name,new GroupedDropDownParameterEditor.DropDownItem(endpoint.Name, collection.Name, endpoint.Id.ToString()))
{
foreach (var collection in _endpointCollectionService.GetEndpointCollections().OrderBy(ec => ec.Sorting))
{
var parameterOptions = _endpointCollectionService.GetEndpoints(collection.Id).Select(endpoint =>
new ParameterOption(endpoint.Name, new GroupedDropDownParameterEditor.DropDownItem(endpoint.Name, collection.Name, endpoint.Id.ToString()))
{
Group = collection.Name
});
result.AddRange(parameterOptions);
}
result.AddRange(parameterOptions);
}
result.AddRange(_endpointService.GetEndpoints().Where(e => e.Collection == null).Select(endpoint =>
new ParameterOption(endpoint.Name, new GroupedDropDownParameterEditor.DropDownItem(endpoint.Name, "Dynamicweb 9 Endpoints", endpoint.Id.ToString()))
{
Group = "Dynamicweb 9 Endpoints"
}));
new ParameterOption(endpoint.Name, new GroupedDropDownParameterEditor.DropDownItem(endpoint.Name, "Dynamicweb 9 Endpoints", endpoint.Id.ToString()))
{
Group = "Dynamicweb 9 Endpoints"
}));

return result;
}
Expand Down Expand Up @@ -302,34 +302,36 @@ public override void OverwriteDestinationSchemaToOriginal()
/// <inheritdoc />
public override Schema GetOriginalSourceSchema()
{
var name = GetEntityName();
var entityTypeTables = new Schema();
var entitySetsTables = new Schema();

if (_endpoint == null)
{
return new Schema();
}

var name = GetEntityName();
var header = new Dictionary<string, string>
{
{ "accept", "text/html,application/xhtml+xml,application/xml" },
{ "Content-Type", "text/html" }
};
if (_endpoint != null)
var endpointAuthentication = _endpoint.Authentication;
if (endpointAuthentication != null)
{
var endpointAuthentication = _endpoint.Authentication;
if (endpointAuthentication != null)
{
SetCredentials();
}
Task metadataResponse;
if (endpointAuthentication.IsTokenBased())
{
string token = OAuthHelper.GetToken(_endpoint, endpointAuthentication);
metadataResponse = new HttpRestClient(_credentials, 20).GetAsync(GetMetadataURL(), HandleStream, token);
}
else
{
metadataResponse = new HttpRestClient(_credentials, 20).GetAsync(GetMetadataURL(), HandleStream, endpointAuthentication, header);
}
metadataResponse.Wait();
SetCredentials();
}
Task metadataResponse;
if (endpointAuthentication.IsTokenBased())
{
string token = OAuthHelper.GetToken(_endpoint, endpointAuthentication);
metadataResponse = new HttpRestClient(_credentials, 20).GetAsync(GetMetadataURL(), HandleStream, token);
}
else
{
metadataResponse = new HttpRestClient(_credentials, 20).GetAsync(GetMetadataURL(), HandleStream, endpointAuthentication, header);
}
metadataResponse.Wait();

var emptySchema = new Schema();
if (entitySetsTables == emptySchema)
Expand Down
Loading