private async Task <IActionResult> InternalUpdate(string id, RepresentationParameter representationParameter) { _logger.LogInformation(string.Format(Global.UpdateResource, id)); try { var newRepresentation = await _replaceRepresentationCommandHandler.Handle(new ReplaceRepresentationCommand(id, _resourceType, representationParameter)); return(BuildHTTPResult(newRepresentation, HttpStatusCode.OK, false)); } catch (SCIMSchemaViolatedException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.BadRequest, ex.Message, SCIMConstants.ErrorSCIMTypes.SchemaViolated)); } catch (SCIMBadSyntaxException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.BadRequest, ex.Message, SCIMConstants.ErrorSCIMTypes.InvalidSyntax)); } catch (SCIMImmutableAttributeException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.BadRequest, ex.Message, SCIMConstants.ErrorSCIMTypes.Mutability)); } catch (SCIMNotFoundException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.NotFound, ex.Message, SCIMConstants.ErrorSCIMTypes.Unknown)); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.InternalServerError, ex.ToString(), SCIMConstants.ErrorSCIMTypes.InternalServerError)); } }
protected async Task <IActionResult> InternalUpdate(string id, RepresentationParameter representationParameter) { if (representationParameter == null) { return(this.BuildError(HttpStatusCode.BadRequest, Global.HttpPutNotWellFormatted, SCIMConstants.ErrorSCIMTypes.InvalidSyntax)); } _logger.LogInformation(Global.UpdateResource, id); try { var newRepresentation = await _replaceRepresentationCommandHandler.Handle(new ReplaceRepresentationCommand(id, _resourceType, representationParameter, Request.GetAbsoluteUriWithVirtualPath())); var location = GetLocation(newRepresentation); var content = newRepresentation.ToResponse(location, false); if (SCIMConstants.MappingScimResourceTypeToCommonType.ContainsKey(_resourceType)) { await _busControl.Publish(new RepresentationUpdatedEvent(newRepresentation.Id, newRepresentation.Version, SCIMConstants.MappingScimResourceTypeToCommonType[_resourceType], content, _options.IncludeToken ? Request.GetToken() : string.Empty)); } return(BuildHTTPResult(HttpStatusCode.OK, location, newRepresentation.Version, content)); } catch (SCIMUniquenessAttributeException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.Conflict, ex.Message, SCIMConstants.ErrorSCIMTypes.Uniqueness)); } catch (SCIMSchemaViolatedException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.BadRequest, ex.Message, SCIMConstants.ErrorSCIMTypes.SchemaViolated)); } catch (SCIMBadSyntaxException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.BadRequest, ex.Message, SCIMConstants.ErrorSCIMTypes.InvalidSyntax)); } catch (SCIMImmutableAttributeException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.BadRequest, ex.Message, SCIMConstants.ErrorSCIMTypes.Mutability)); } catch (SCIMNotFoundException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.NotFound, ex.Message, SCIMConstants.ErrorSCIMTypes.Unknown)); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.InternalServerError, ex.ToString(), SCIMConstants.ErrorSCIMTypes.InternalServerError)); } }
protected async Task <IActionResult> InternalUpdate(string id, RepresentationParameter representationParameter) { if (representationParameter == null) { return(this.BuildError(HttpStatusCode.BadRequest, Global.HttpPutNotWellFormatted, SCIMConstants.ErrorSCIMTypes.InvalidSyntax)); } _logger.LogInformation(string.Format(Global.UpdateResource, id)); try { var newRepresentation = await _replaceRepresentationCommandHandler.Handle(new ReplaceRepresentationCommand(id, _resourceType, representationParameter)); var location = GetLocation(newRepresentation); var content = newRepresentation.ToResponse(location, false); await _busControl.Publish(new RepresentationUpdatedEvent(newRepresentation.Id, newRepresentation.VersionNumber, _resourceType, content)); return(BuildHTTPResult(HttpStatusCode.OK, location, newRepresentation.Version, content)); } catch (SCIMSchemaViolatedException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.BadRequest, ex.Message, SCIMConstants.ErrorSCIMTypes.SchemaViolated)); } catch (SCIMBadSyntaxException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.BadRequest, ex.Message, SCIMConstants.ErrorSCIMTypes.InvalidSyntax)); } catch (SCIMImmutableAttributeException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.BadRequest, ex.Message, SCIMConstants.ErrorSCIMTypes.Mutability)); } catch (SCIMNotFoundException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.NotFound, ex.Message, SCIMConstants.ErrorSCIMTypes.Unknown)); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.InternalServerError, ex.ToString(), SCIMConstants.ErrorSCIMTypes.InternalServerError)); } }
private async Task <IActionResult> InternalUpdate(string id, JObject jObj) { try { var newRepresentation = await _replaceRepresentationCommandHandler.Handle(new ReplaceRepresentationCommand(id, _schemas.Select(s => s.Id).ToList(), jObj)); return(BuildHTTPResult(newRepresentation, HttpStatusCode.OK, false)); } catch (SCIMBadRequestException) { return(this.BuildError(HttpStatusCode.BadRequest, "Request is unparsable, syntactically incorrect, or violates schema.", "invalidSyntax")); } catch (SCIMImmutableAttributeException) { return(this.BuildError(HttpStatusCode.BadRequest, "The attempted modification is not compatible with the target attribute's mutability or current state (e.g., modification of an \"immutable\" attribute with an existing value).", "mutability")); } catch (SCIMNotFoundException) { return(this.BuildError(HttpStatusCode.NotFound, "Resource does not exist", "notFound")); } }