private bool TryGetProjectSectionFromRoot(ArtifactVersion artifactVersion, out ProjectSection?projectSection) { projectSection = null; if (artifactVersion == null) { return(false); } if (artifactVersion.ItemTypePredefined == ItemTypePredefined.Project) { projectSection = ProjectSection.Artifacts; return(true); } // Collections and Baselines/Reviews roots are under the project if (artifactVersion.ParentId != artifactVersion.VersionProjectId) { return(false); } if (artifactVersion.ItemTypePredefined == ItemTypePredefined.CollectionFolder) { projectSection = ProjectSection.Collections; return(true); } if (artifactVersion.ItemTypePredefined == ItemTypePredefined.BaselineFolder) { projectSection = ProjectSection.BaselinesAndReviews; return(true); } return(false); }
private bool BelongsToProjectSection(ArtifactVersion artifactVersion, ProjectSection projectSection) { var itp = artifactVersion.ItemTypePredefined.GetValueOrDefault(); switch (projectSection) { case ProjectSection.Artifacts: return(itp.IsRegularArtifactType()); case ProjectSection.Collections: return(itp.IsCollectionsGroupType()); case ProjectSection.BaselinesAndReviews: return(itp.IsBaselinesAndReviewsGroupType()); default: return(false); } }
private ArtifactVersion FindAncestorOrProjectUserVersionWithDirectPermissions(Dictionary <int, ArtifactVersion> dicUserArtifactVersions, ArtifactVersion parentUserVersion, int projectId) { if (parentUserVersion?.ParentId == null) { return(null); } ArtifactVersion directAncestorUserVersion; dicUserArtifactVersions.TryGetValue(parentUserVersion.ParentId.GetValueOrDefault(), out directAncestorUserVersion); if (directAncestorUserVersion == null) { ArtifactVersion projectUserArtifactVersion; dicUserArtifactVersions.TryGetValue(projectId, out projectUserArtifactVersion); return(projectUserArtifactVersion?.DirectPermissions != null ? projectUserArtifactVersion : null); } return(directAncestorUserVersion.DirectPermissions != null ? directAncestorUserVersion : FindAncestorOrProjectUserVersionWithDirectPermissions(dicUserArtifactVersions, directAncestorUserVersion, projectId)); }
private List <ArtifactVersion> FindVisibleChildren(Dictionary <int, ArtifactVersion> dicUserArtifactVersions, ArtifactVersion parentUserArtifactVersion) { return(dicUserArtifactVersions.Values. Where(v => v?.ParentId == parentUserArtifactVersion.ItemId && (v.DirectPermissions == null || v.DirectPermissions.Value.HasFlag(RolePermissions.Read))).ToList()); }
private List <ArtifactVersion> ProcessChildren(Dictionary <int, ArtifactVersion> dicUserArtifactVersions, ArtifactVersion parentUserArtifactVersion) { var children = FindVisibleChildren(dicUserArtifactVersions, parentUserArtifactVersion); children.ForEach(v => { v.HasChildren = FindVisibleChildren(dicUserArtifactVersions, v).Count > 0; v.EffectivePermissions = v.DirectPermissions ?? parentUserArtifactVersion.EffectivePermissions; }); return(children); }