public async Task <IActionResult> Get() { var searchRequest = SearchSCIMResourceParameter.Create(Request.Query); try { if (searchRequest.Count > _options.MaxResults) { searchRequest.Count = _options.MaxResults; } var result = await _scimRepresentationQueryRepository.FindSCIMRepresentations(new SearchSCIMRepresentationsParameter(_scimEndpoint, searchRequest.StartIndex, searchRequest.Count, searchRequest.SortBy, searchRequest.SortOrder, SCIMFilterParser.Parse(searchRequest.Filter, _schemas))); var jObj = new JObject { { SCIMConstants.StandardSCIMRepresentationAttributes.Schemas, new JArray(new [] { SCIMConstants.StandardSchemas.ListResponseSchemas.Id }) }, { SCIMConstants.StandardSCIMRepresentationAttributes.TotalResults, result.TotalResults }, { SCIMConstants.StandardSCIMRepresentationAttributes.ItemsPerPage, searchRequest.Count }, { SCIMConstants.StandardSCIMRepresentationAttributes.StartIndex, searchRequest.StartIndex } }; var resources = new JArray(); foreach (var record in result.Content) { JObject newJObj = null; var location = $"{Request.GetAbsoluteUriWithVirtualPath()}/{_scimEndpoint}/{record.Id}"; if (searchRequest.Attributes.Any()) { newJObj = record.ToResponseWithIncludedAttributes(searchRequest.Attributes.Select(a => SCIMFilterParser.Parse(a, _schemas)).ToList()); } else if (searchRequest.ExcludedAttributes.Any()) { newJObj = record.ToResponseWithExcludedAttributes(searchRequest.ExcludedAttributes.Select(a => SCIMFilterParser.Parse(a, _schemas)).ToList(), location); } else { newJObj = record.ToResponse(location, true); } resources.Add(newJObj); } jObj.Add(SCIMConstants.StandardSCIMRepresentationAttributes.Resources, resources); return(new ContentResult { StatusCode = (int)HttpStatusCode.OK, Content = jObj.ToString(), ContentType = SCIMConstants.STANDARD_SCIM_CONTENT_TYPE }); } catch (SCIMFilterException ex) { return(this.BuildError(HttpStatusCode.BadRequest, ex.Message, "invalidFilter")); } }
public Task <IActionResult> Get() { var searchRequest = SearchSCIMResourceParameter.Create(Request.Query); return(InternalSearch(searchRequest)); }
public Task <IActionResult> Search([FromBody] JObject jObj) { var searchRequest = SearchSCIMResourceParameter.Create(jObj); return(InternalSearch(searchRequest)); }
public async Task <IActionResult> Get() { _logger.LogInformation(Global.StartGetResources); var searchRequest = SearchSCIMResourceParameter.Create(Request.Query); try { if (searchRequest.Count > _options.MaxResults) { searchRequest.Count = _options.MaxResults; } var schema = await _scimSchemaQueryRepository.FindRootSCIMSchemaByResourceType(_resourceType); var schemaIds = new List <string> { schema.Id }; schemaIds.AddRange(schema.SchemaExtensions.Select(s => s.Schema)); var schemas = (await _scimSchemaQueryRepository.FindSCIMSchemaByIdentifiers(schemaIds)).ToList(); var result = await _scimRepresentationQueryRepository.FindSCIMRepresentations(new SearchSCIMRepresentationsParameter(_resourceType, searchRequest.StartIndex, searchRequest.Count, searchRequest.SortBy, searchRequest.SortOrder, SCIMFilterParser.Parse(searchRequest.Filter, schemas))); var jObj = new JObject { { SCIMConstants.StandardSCIMRepresentationAttributes.Schemas, new JArray(new [] { SCIMConstants.StandardSchemas.ListResponseSchemas.Id }) }, { SCIMConstants.StandardSCIMRepresentationAttributes.TotalResults, result.TotalResults }, { SCIMConstants.StandardSCIMRepresentationAttributes.ItemsPerPage, searchRequest.Count }, { SCIMConstants.StandardSCIMRepresentationAttributes.StartIndex, searchRequest.StartIndex } }; var resources = new JArray(); var baseUrl = Request.GetAbsoluteUriWithVirtualPath(); var representations = result.Content.ToList(); await _attributeReferenceEnricher.Enrich(_resourceType, representations, baseUrl); foreach (var record in representations) { JObject newJObj = null; var location = $"{baseUrl}/{_resourceType}/{record.Id}"; if (searchRequest.Attributes.Any()) { newJObj = record.ToResponseWithIncludedAttributes(searchRequest.Attributes.Select(a => SCIMFilterParser.Parse(a, schemas)).ToList()); } else if (searchRequest.ExcludedAttributes.Any()) { newJObj = record.ToResponseWithExcludedAttributes(searchRequest.ExcludedAttributes.Select(a => SCIMFilterParser.Parse(a, schemas)).ToList(), location); } else { newJObj = record.ToResponse(location, true); } resources.Add(newJObj); } jObj.Add(SCIMConstants.StandardSCIMRepresentationAttributes.Resources, resources); return(new ContentResult { StatusCode = (int)HttpStatusCode.OK, Content = jObj.ToString(), ContentType = SCIMConstants.STANDARD_SCIM_CONTENT_TYPE }); } catch (SCIMFilterException ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.BadRequest, ex.Message, SCIMConstants.ErrorSCIMTypes.InvalidFilter)); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(this.BuildError(HttpStatusCode.InternalServerError, ex.ToString(), SCIMConstants.ErrorSCIMTypes.InternalServerError)); } }