Ejemplo n.º 1
0
        private List <ScanSummaryView> GetPendingScans(String projectName, String projectVersion)
        {
            List <ScanSummaryView> pendingScans = new List <ScanSummaryView>();

            try
            {
                ProjectView        projectItem        = projectDataService.GetProjectView(projectName);
                ProjectVersionView projectVersionItem = projectVersionDataService.GetProjectVersion(projectItem, projectVersion);
                string             projectVersionUrl  = projectVersionItem.Metadata.Href;

                List <CodeLocationView> allCodeLocations      = codeLocationDataService.GetAllCodeLocationsForCodeLocationType(CodeLocationTypeEnum.BOM_IMPORT);
                List <string>           allScanSummariesLinks = new List <string>();
                foreach (CodeLocationView codeLocationItem in allCodeLocations)
                {
                    string mappedProjectVersionUrl = codeLocationItem.MappedProjectVersion;
                    if (projectVersionUrl.Equals(mappedProjectVersionUrl))
                    {
                        string scanSummariesLink = MetadataResponseService.GetLink(codeLocationItem, ApiLinks.SCANS_LINK);
                        allScanSummariesLinks.Add(scanSummariesLink);
                    }
                }

                List <ScanSummaryView> allScanSummaries = new List <ScanSummaryView>();
                foreach (string scanSummaryLink in allScanSummariesLinks)
                {
                    allScanSummaries.AddRange(scanSummaryDataService.GetAllItems <ScanSummaryView>(scanSummaryLink));
                }

                pendingScans = new List <ScanSummaryView>();
                foreach (ScanSummaryView scanSummaryItem in allScanSummaries)
                {
                    if (IsPending(scanSummaryItem.Status))
                    {
                        pendingScans.Add(scanSummaryItem);
                    }
                }
            }
            catch (Exception ex)
            {
                pendingScans = new List <ScanSummaryView>();
                // ignore, since we might not have found a project or version, etc
                // so just keep waiting until the timeout
            }

            return(pendingScans);
        }