Skip to content

Commit da56fe3

Browse files
Ticket #306 : Always publish events when references are updated
1 parent 8f8447e commit da56fe3

6 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/Scim/SimpleIdServer.Scim/Api/BaseApiController.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ protected async Task<IActionResult> InternalAdd(RepresentationParameter jobj)
281281
try
282282
{
283283
var command = new AddRepresentationCommand(_resourceType, jobj, _uriProvider.GetAbsoluteUriWithVirtualPath());
284-
var scimRepresentation = await _addRepresentationCommandHandler.Handle(command, IsPublishEvtsEnabled);
284+
var scimRepresentation = await _addRepresentationCommandHandler.Handle(command);
285285
var location = GetLocation(scimRepresentation);
286286
var content = scimRepresentation.ToResponse(location, false, mergeExtensionAttributes: _options.MergeExtensionAttributes);
287287
if (IsPublishEvtsEnabled) await _busControl.Publish(new RepresentationAddedEvent(scimRepresentation.Id, scimRepresentation.Version, GetResourceType(scimRepresentation.ResourceType), content, _options.IncludeToken ? Request.GetToken() : string.Empty));
@@ -314,7 +314,7 @@ protected async Task<IActionResult> InternalDelete(string id)
314314
_logger.LogInformation(string.Format(Global.DeleteResource, id));
315315
try
316316
{
317-
var representation = await _deleteRepresentationCommandHandler.Handle(new DeleteRepresentationCommand(id, _resourceType, _uriProvider.GetAbsoluteUriWithVirtualPath()), IsPublishEvtsEnabled);
317+
var representation = await _deleteRepresentationCommandHandler.Handle(new DeleteRepresentationCommand(id, _resourceType, _uriProvider.GetAbsoluteUriWithVirtualPath()));
318318
if(IsPublishEvtsEnabled) await _busControl.Publish(new RepresentationRemovedEvent(id, representation.Version, GetResourceType(_resourceType), _options.IncludeToken ? Request.GetToken() : string.Empty));
319319
return new StatusCodeResult((int)HttpStatusCode.NoContent);
320320
}
@@ -340,7 +340,7 @@ protected async Task<IActionResult> InternalUpdate(string id, RepresentationPara
340340
_logger.LogInformation(Global.UpdateResource, id);
341341
try
342342
{
343-
var newRepresentation = await _replaceRepresentationCommandHandler.Handle(new ReplaceRepresentationCommand(id, _resourceType, representationParameter, _uriProvider.GetAbsoluteUriWithVirtualPath()), IsPublishEvtsEnabled);
343+
var newRepresentation = await _replaceRepresentationCommandHandler.Handle(new ReplaceRepresentationCommand(id, _resourceType, representationParameter, _uriProvider.GetAbsoluteUriWithVirtualPath()));
344344
var location = GetLocation(newRepresentation);
345345
var content = newRepresentation.ToResponse(location, false, mergeExtensionAttributes: _options.MergeExtensionAttributes);
346346
if (IsPublishEvtsEnabled) await _busControl.Publish(new RepresentationUpdatedEvent(newRepresentation.Id, newRepresentation.Version, GetResourceType(_resourceType), content, _options.IncludeToken ? Request.GetToken() : string.Empty));
@@ -383,7 +383,7 @@ protected async Task<IActionResult> InternalPatch(string id, PatchRepresentation
383383
_logger.LogInformation(string.Format(Global.PatchResource, id, patchRepresentation == null ? string.Empty : JsonConvert.SerializeObject(patchRepresentation)));
384384
try
385385
{
386-
var patchResult = await _patchRepresentationCommandHandler.Handle(new PatchRepresentationCommand(id, ResourceType, patchRepresentation, _uriProvider.GetAbsoluteUriWithVirtualPath()), IsPublishEvtsEnabled);
386+
var patchResult = await _patchRepresentationCommandHandler.Handle(new PatchRepresentationCommand(id, ResourceType, patchRepresentation, _uriProvider.GetAbsoluteUriWithVirtualPath()));
387387
if (!patchResult.IsPatched) return NoContent();
388388
var newRepresentation = patchResult.SCIMRepresentation;
389389
var location = GetLocation(newRepresentation);

src/Scim/SimpleIdServer.Scim/Commands/Handlers/AddRepresentationCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public AddRepresentationCommandHandler(
3737
_representationReferenceSync = representationReferenceSync;
3838
}
3939

40-
public async Task<SCIMRepresentation> Handle(AddRepresentationCommand addRepresentationCommand, bool isPublishEvtsEnabled)
40+
public async Task<SCIMRepresentation> Handle(AddRepresentationCommand addRepresentationCommand)
4141
{
4242
var requestedSchemas = addRepresentationCommand.Representation.Schemas;
4343
if (!requestedSchemas.Any())
@@ -85,7 +85,7 @@ public async Task<SCIMRepresentation> Handle(AddRepresentationCommand addReprese
8585
await transaction.Commit();
8686
}
8787

88-
if (isPublishEvtsEnabled) await Notify(references);
88+
await Notify(references);
8989
scimRepresentation.ApplyEmptyArray();
9090
return scimRepresentation;
9191
}

src/Scim/SimpleIdServer.Scim/Commands/Handlers/DeleteRepresentationCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public DeleteRepresentationCommandHandler(ISCIMRepresentationCommandRepository s
2626
_representationReferenceSync = representationReferenceSync;
2727
}
2828

29-
public async Task<SCIMRepresentation> Handle(DeleteRepresentationCommand request, bool isPublishEvtsEnabled)
29+
public async Task<SCIMRepresentation> Handle(DeleteRepresentationCommand request)
3030
{
3131
var representation = await _scimRepresentationQueryRepository.FindSCIMRepresentationById(request.Id, request.ResourceType);
3232
if (representation == null)
@@ -46,7 +46,7 @@ public async Task<SCIMRepresentation> Handle(DeleteRepresentationCommand request
4646
await transaction.Commit();
4747
}
4848

49-
if (isPublishEvtsEnabled) await Notify(references);
49+
await Notify(references);
5050
return representation;
5151
}
5252
}

src/Scim/SimpleIdServer.Scim/Commands/Handlers/PatchRepresentationCommandHandler.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ public PatchRepresentationCommandHandler(
3939
_options = options.Value;
4040
}
4141

42-
public async Task<PatchRepresentationResult> Handle(PatchRepresentationCommand patchRepresentationCommand, bool isPublishEvtsEnabled)
42+
public async Task<PatchRepresentationResult> Handle(PatchRepresentationCommand patchRepresentationCommand)
4343
{
4444
CheckParameter(patchRepresentationCommand.PatchRepresentation);
4545
var existingRepresentation = await _scimRepresentationQueryRepository.FindSCIMRepresentationById(patchRepresentationCommand.Id);
4646
if (existingRepresentation == null) throw new SCIMNotFoundException(string.Format(Global.ResourceNotFound, patchRepresentationCommand.Id));
47-
return await UpdateRepresentation(existingRepresentation, patchRepresentationCommand, isPublishEvtsEnabled);
47+
return await UpdateRepresentation(existingRepresentation, patchRepresentationCommand);
4848
}
4949

50-
private async Task<PatchRepresentationResult> UpdateRepresentation(SCIMRepresentation existingRepresentation, PatchRepresentationCommand patchRepresentationCommand, bool isPublishEvtsEnabled)
50+
private async Task<PatchRepresentationResult> UpdateRepresentation(SCIMRepresentation existingRepresentation, PatchRepresentationCommand patchRepresentationCommand)
5151
{
5252
var attributeMappings = await _scimAttributeMappingQueryRepository.GetBySourceResourceType(existingRepresentation.ResourceType);
5353
var patchResult = existingRepresentation.ApplyPatches(patchRepresentationCommand.PatchRepresentation.Operations, attributeMappings, _options.IgnoreUnsupportedCanonicalValues);
@@ -65,7 +65,7 @@ private async Task<PatchRepresentationResult> UpdateRepresentation(SCIMRepresent
6565
await transaction.Commit();
6666
}
6767

68-
if (isPublishEvtsEnabled) await Notify(references);
68+
await Notify(references);
6969
existingRepresentation.ApplyEmptyArray();
7070
return PatchRepresentationResult.Ok(existingRepresentation);
7171
}

src/Scim/SimpleIdServer.Scim/Commands/Handlers/ReplaceRepresentationCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public ReplaceRepresentationCommandHandler(
3838
_representationReferenceSync = representationReferenceSync;
3939
}
4040

41-
public async Task<SCIMRepresentation> Handle(ReplaceRepresentationCommand replaceRepresentationCommand, bool isPublishEvtsEnabled)
41+
public async Task<SCIMRepresentation> Handle(ReplaceRepresentationCommand replaceRepresentationCommand)
4242
{
4343
var requestedSchemas = replaceRepresentationCommand.Representation.Schemas;
4444
if (!requestedSchemas.Any())
@@ -87,7 +87,7 @@ public async Task<SCIMRepresentation> Handle(ReplaceRepresentationCommand replac
8787
await transaction.Commit();
8888
}
8989

90-
if (isPublishEvtsEnabled) await Notify(references);
90+
await Notify(references);
9191
existingRepresentation.ApplyEmptyArray();
9292
return existingRepresentation;
9393
}

src/Scim/SimpleIdServer.Scim/Infrastructure/ISCIMCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ namespace SimpleIdServer.Scim.Infrastructure
66
{
77
public interface ISCIMCommandHandler<TCommand, TResult> where TCommand : ISCIMCommand<TResult>
88
{
9-
Task<TResult> Handle(TCommand request, bool isPublishEvtsEnabled);
9+
Task<TResult> Handle(TCommand request);
1010
}
1111
}

0 commit comments

Comments
 (0)