public async Task CheckSiteChilds <T, U>(bool isRecordManagement, List <ChildrenARM <T, U> > childs, bool groupStructure, string guid, List <GroupModel> configGroups) { var documentLibrary = await _alfrescoHttpClient.GetNodeInfo(guid, ImmutableList <Parameter> .Empty .Add(new Parameter(AlfrescoNames.Headers.RelativePath, AlfrescoNames.DocumentLibrary, ParameterType.QueryString))); var documentLibraryId = documentLibrary?.Entry?.Id; if (documentLibraryId == null) { Log.Error($"{guid} documentlibrary doesn't exist"); return; } if (!groupStructure) { await CreateChilds(childs, documentLibraryId); return; } foreach (var group in configGroups.Where(x => x?.Body?.Id != null)) { var permissions = Enum.GetValues(typeof(GroupPermissionTypes)).Cast <GroupPermissionTypes>().Select(x => new Permission { Id = $"{group.Body.Id}_{x}", Role = x.ToString() }).ToList(); permissions.Insert(0, new Permission { Id = group.Body.Id, Role = "Consumer" }); permissions.Insert(0, new Permission { Id = $"{group.Body.Id}_Sign", Role = "Collaborator" }); string nodeId = null; try { var groupFolder = await _alfrescoHttpClient.GetNodeInfo(documentLibraryId, ImmutableList <Parameter> .Empty .Add(new Parameter(AlfrescoNames.Headers.RelativePath, group.Body.Id, ParameterType.QueryString))); nodeId = groupFolder?.Entry?.Id; } catch { } if (nodeId == null) { try { if (isRecordManagement) { var result = await _alfrescoHttpClient.CreateRecordCategory(documentLibraryId, new NodeBodyCreate { Name = group.Body.Id, NodeType = "rma:recordFolder", Properties = new Dictionary <string, object> { { "cm:title", group.Body.DisplayName }, { "cm:description", group.Body.DisplayName } } }); nodeId = result?.Entry?.Id; // update permissions await SetPermissionInheritence(nodeId); } else { var result = await _alfrescoHttpClient.CreateNode(documentLibraryId, new NodeBodyCreate { Name = group.Body.Id, NodeType = "cm:folder", Properties = new Dictionary <string, object> { { "cm:title", group.Body.DisplayName }, { "cm:description", group.Body.DisplayName } } }); nodeId = result?.Entry?.Id; } } catch (Exception ex) { Log.Error(ex, "CheckSiteChilds Fail"); } } await CheckCreatePermissions(nodeId, permissions); await CreateChilds(childs, nodeId); } }