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
Expand Up @@ -5,7 +5,7 @@
using OneGround.ZGW.Besluiten.DataModel;
using OneGround.ZGW.Catalogi.ServiceAgent.v1;
using OneGround.ZGW.Common.Contracts.v1;
using OneGround.ZGW.Documenten.ServiceAgent.v1;
using OneGround.ZGW.Documenten.ServiceAgent.v1._7;

namespace OneGround.ZGW.Besluiten.Web.BusinessRules;

Expand Down
9 changes: 4 additions & 5 deletions src/OneGround.ZGW.Besluiten.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
using OneGround.ZGW.Common.Web.Services;
using OneGround.ZGW.Common.Web.Swagger;
using OneGround.ZGW.DataAccess;
using OneGround.ZGW.Documenten.ServiceAgent.v1._5.Extensions;
using OneGround.ZGW.Documenten.ServiceAgent.v1.Extensions;
using OneGround.ZGW.Documenten.ServiceAgent.v1._5.Extensions; // For ZRC/BRC v1.5 expands only
using OneGround.ZGW.Documenten.ServiceAgent.v1._7.Extensions;
using OneGround.ZGW.Notificaties.ServiceAgent.Extensions;
using OneGround.ZGW.Zaken.ServiceAgent.v1.Extensions;

Expand Down Expand Up @@ -88,9 +88,8 @@ public void ConfigureServices(IServiceCollection services)
services.AddBesluitenServiceAgent(Configuration);
services.AddCatalogiServiceAgent(Configuration);
services.AddCatalogiServiceAgent_v1_3(Configuration);
services.AddDocumentenServiceAgent(Configuration);
services.AddServiceAuthDocumentenServiceAgent_v1_5(Configuration);
services.AddUserAuthDocumentenServiceAgent_v1_5(Configuration);
services.AddDocumentenServiceAgent_v1_7(Configuration);
services.AddUserAuthDocumentenServiceAgent_v1_5(Configuration); // For ZRC/BRC v1.5 expands only
Comment thread
heuvea marked this conversation as resolved.
Dismissed

// Expanders support _expand in responses
services.AddExpandables();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using OneGround.ZGW.Common.ServiceAgent.Extensions;
using OneGround.ZGW.Documenten.Contracts.v1.Requests;
using OneGround.ZGW.Documenten.Jobs.Extensions;
using OneGround.ZGW.Documenten.ServiceAgent.v1;
using OneGround.ZGW.Documenten.ServiceAgent.v1._7;

namespace OneGround.ZGW.Documenten.Jobs.InformatieObjecten;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using OneGround.ZGW.Common.Authentication;
using OneGround.ZGW.Common.ServiceAgent.Extensions;
using OneGround.ZGW.Documenten.Jobs.Extensions;
using OneGround.ZGW.Documenten.ServiceAgent.v1;
using OneGround.ZGW.Documenten.ServiceAgent.v1._7;

namespace OneGround.ZGW.Documenten.Jobs.InformatieObjecten;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.Extensions.Logging;
using OneGround.ZGW.Common.Authentication;
using OneGround.ZGW.Documenten.ServiceAgent.v1;
using OneGround.ZGW.Documenten.ServiceAgent.v1._7;

namespace OneGround.ZGW.Documenten.Jobs.InformatieObjecten;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using OneGround.ZGW.Documenten.DataModel;
using OneGround.ZGW.Documenten.Jobs;
using OneGround.ZGW.Documenten.Messaging.Configuration;
using OneGround.ZGW.Documenten.ServiceAgent.v1.Extensions;
using OneGround.ZGW.Documenten.ServiceAgent.v1._7.Extensions;
using OneGround.ZGW.Notificaties.ServiceAgent.Extensions;

namespace OneGround.ZGW.Documenten.Messaging;
Expand Down Expand Up @@ -56,7 +56,7 @@ public void ConfigureServices(IServiceCollection services)

services.AddSingleton<DocumentenHangfireConnectionFactory>();

services.AddDocumentenServiceAgent(_configuration);
services.AddDocumentenServiceAgent_v1_7(_configuration);
services.AddNotificatiesServiceAgent(_configuration);

services.AddScoped<IAutorisatiesServiceAgent, AutorisatiesServiceAgent>();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace OneGround.ZGW.Documenten.ServiceAgent.v1._5;

[Obsolete("This class is obsolete. Use the new expand/field-selection and registration mechanism instead.")]
public class DocumentenServiceAgent : ZGWServiceAgent<DocumentenServiceAgent>, IDocumentenServiceAgent
{
public DocumentenServiceAgent(
Expand All @@ -28,6 +29,18 @@ IConfiguration configuration
Client.DefaultRequestHeaders.Add("Api-Version", "1.5");
}

public async Task<ServiceAgentResponse<EnkelvoudigInformatieObjectResponseDto>> GetEnkelvoudigInformatieObjectByUrlAsync(
string enkelvoudigInformatieObjectUrl
)
{
if (!EnsureValidResource(ServiceRoleName.DRC, enkelvoudigInformatieObjectUrl, "enkelvoudiginformatieobjecten", out var errorResponse))
return new ServiceAgentResponse<EnkelvoudigInformatieObjectResponseDto>(errorResponse);

Logger.LogDebug("Query EnkelvoudigInformatieObject {enkelvoudigInformatieObjectUrl}....", enkelvoudigInformatieObjectUrl);

return await GetAsync<EnkelvoudigInformatieObjectResponseDto>(new Uri(enkelvoudigInformatieObjectUrl));
}

public async Task<
ServiceAgentResponse<(EnkelvoudigInformatieObjectResponseDto enkelvoudigInformatieObject, object expandedEnkelvoudigInformatieObject)>
> GetEnkelvoudigInformatieObjectByUrlAsync(string enkelvoudigInformatieObjectUrl, string expand)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using OneGround.ZGW.Common.Constants;
Expand All @@ -7,12 +8,7 @@ namespace OneGround.ZGW.Documenten.ServiceAgent.v1._5.Extensions;

public static class DocumentenServiceAgentExtensions
{
public static void AddServiceAuthDocumentenServiceAgent_v1_5(this IServiceCollection services, IConfiguration configuration)
{
// Service-account authorized ServiceAgent like "oneground-09435039" (for system cross-API like add/deleting mirrored zrc/brc relations)
services.AddServiceAgent<IDocumentenServiceAgent, DocumentenServiceAgent>(ServiceRoleName.DRC, configuration);
}

[Obsolete("This class is obsolete. Use the new expand/field-selection and registration mechanism instead.")]
public static void AddUserAuthDocumentenServiceAgent_v1_5(this IServiceCollection services, IConfiguration configuration)
{
// User authorized ServiceAgent (for user cross-API expands like ZRC->DRC / BRC->DRC)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using OneGround.ZGW.Common.ServiceAgent;
Expand All @@ -6,8 +7,12 @@

namespace OneGround.ZGW.Documenten.ServiceAgent.v1._5;

[Obsolete("This class is obsolete. Use the new expand/field-selection and registration mechanism instead.")]
public interface IDocumentenServiceAgent
{
Task<ServiceAgentResponse<EnkelvoudigInformatieObjectResponseDto>> GetEnkelvoudigInformatieObjectByUrlAsync(
string enkelvoudigInformatieObjectUrl
);
Task<
ServiceAgentResponse<(EnkelvoudigInformatieObjectResponseDto enkelvoudigInformatieObject, object expandedEnkelvoudigInformatieObject)>
> GetEnkelvoudigInformatieObjectByUrlAsync(string enkelvoudigInformatieObjectUrl, string expand);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using System;

namespace OneGround.ZGW.Documenten.ServiceAgent.v1._5;

[Obsolete("This class is obsolete. Use the new expand/field-selection and registration mechanism instead.")]
public interface IUserAuthDocumentenServiceAgent : IDocumentenServiceAgent;
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Net.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
Expand All @@ -6,6 +7,7 @@

namespace OneGround.ZGW.Documenten.ServiceAgent.v1._5;

[Obsolete("This class is obsolete. Use the new expand/field-selection and registration mechanism instead.")]
public class UserAuthDocumentenServiceAgent : DocumentenServiceAgent, IUserAuthDocumentenServiceAgent
{
public UserAuthDocumentenServiceAgent(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using OneGround.ZGW.Common.Contracts.v1.AuditTrail;
using OneGround.ZGW.Common.ServiceAgent;
using OneGround.ZGW.Documenten.Contracts.v1.Requests;
using OneGround.ZGW.Documenten.Contracts.v1.Responses;
using OneGround.ZGW.Documenten.Contracts.v1._7.Queries;
using OneGround.ZGW.Documenten.Contracts.v1._7.Requests;
using OneGround.ZGW.Documenten.Contracts.v1._7.Responses;

namespace OneGround.ZGW.Documenten.ServiceAgent.v1;
namespace OneGround.ZGW.Documenten.ServiceAgent.v1._7;

class CachedDocumentServiceAgent : ICachedDocumentenServiceAgent
{
private readonly IDocumentenServiceAgent _agent;
private readonly ConcurrentDictionary<
string,
ServiceAgentResponse<EnkelvoudigInformatieObjectResponseDto>
> _cachedEnkelvoudigInformatieObjectUrl = new();
Comment thread
heuvea marked this conversation as resolved.

public CachedDocumentServiceAgent(IDocumentenServiceAgent agent)
{
Expand All @@ -26,13 +34,34 @@ EnkelvoudigInformatieObjectCreateRequestDto enkelvoudigInformatieObject
}

public Task<ServiceAgentResponse<ObjectInformatieObjectResponseDto>> AddObjectInformatieObjectAsync(
ObjectInformatieObjectRequestDto objectInformatieObject
Contracts.v1.Requests.ObjectInformatieObjectRequestDto objectInformatieObject
)
{
// Note: Pass through agent (so no cache)
return _agent.AddObjectInformatieObjectAsync(objectInformatieObject);
}

public Task<ServiceAgentResponse<EnkelvoudigInformatieObjectResponseDto>> GetEnkelvoudigInformatieObjectAsync(Guid enkelvoudigInformatieObjectId)
{
// Note: Pass through agent (so no cache)
return _agent.GetEnkelvoudigInformatieObjectAsync(enkelvoudigInformatieObjectId);
}

public Task<ServiceAgentResponse<Contracts.v1._1.Responses.BestandsDeelResponseDto>> AddBestandsdeelAsync(
string bestandsdeelUrl,
MultipartFormDataContent multipartFormDataContent
)
{
// Note: Pass through agent (so no cache)
return _agent.AddBestandsdeelAsync(bestandsdeelUrl, multipartFormDataContent);
}

public Task<ServiceAgentResponse> UnlockAsync(string enkelvoudigInformatieObjectUrl)
{
// Note: Pass through agent (so no cache)
return _agent.UnlockAsync(enkelvoudigInformatieObjectUrl);
}

public Task<ServiceAgentResponse> DeleteEnkelvoudigInformatieObjectByUrlAsync(string enkelvoudigInformatieObjectUrl)
{
// Note: Pass through agent (so no cache)
Expand Down Expand Up @@ -68,14 +97,24 @@ string enkelvoudigInformatieObjectUrl
{
return cachedEnkelvoudigInformatieObject;
}
_cachedEnkelvoudigInformatieObjectUrl[enkelvoudigInformatieObjectUrl] = await _agent.GetEnkelvoudigInformatieObjectByUrlAsync(
enkelvoudigInformatieObjectUrl
);

return _cachedEnkelvoudigInformatieObjectUrl[enkelvoudigInformatieObjectUrl];
var result = await _agent.GetEnkelvoudigInformatieObjectByUrlAsync(enkelvoudigInformatieObjectUrl);
if (result.Success)
{
// Note: Only cache successful responses, so a transient failure isn't replayed for the rest of the scope
_cachedEnkelvoudigInformatieObjectUrl[enkelvoudigInformatieObjectUrl] = result;
}

return result;
}

private readonly Dictionary<string, ServiceAgentResponse<EnkelvoudigInformatieObjectResponseDto>> _cachedEnkelvoudigInformatieObjectUrl = [];
public Task<
ServiceAgentResponse<(EnkelvoudigInformatieObjectResponseDto enkelvoudigInformatieObject, object expandedEnkelvoudigInformatieObject)>
> GetEnkelvoudigInformatieObjectByUrlAsync(string enkelvoudigInformatieObjectUrl, string expand)
{
// Note: Pass through agent (so no cache)
return _agent.GetEnkelvoudigInformatieObjectByUrlAsync(enkelvoudigInformatieObjectUrl, expand);
}

public Task<ServiceAgentResponse<IEnumerable<ObjectInformatieObjectResponseDto>>> GetObjectInformatieObjectsByInformatieObjectAndObjectAsync(
string informatieObject,
Expand All @@ -85,4 +124,12 @@ string @object
// Note: Pass through agent for now (so no cache yet due to too many memory resources kept in cache; or limit amount of cache-entries)
return _agent.GetObjectInformatieObjectsByInformatieObjectAndObjectAsync(informatieObject, @object);
}

public Task<ServiceAgentResponse<IEnumerable<ObjectInformatieObjectResponseDto>>> GetObjectInformatieObjectenAsync(
GetAllObjectInformatieObjectenQueryParameters parameters
)
{
// Note: Pass through agent (so no cache)
return _agent.GetObjectInformatieObjectenAsync(parameters);
}
}
Loading
Loading