public override async Task CurateAsync(Package galleryPackage, PackageArchiveReader nugetPackage, bool commitChanges)
        {
            // Make sure the target feed exists
            CuratedFeed feed = CuratedFeedService.GetFeedByName(CuratedFeedName, includePackages: true);

            if (feed != null && galleryPackage.Tags != null)
            {
                // Break the tags up so we can be sure we don't catch any partial matches (i.e. "foobar" when we're looking for "foo")
                string[] tags = galleryPackage.Tags.Split();

                // Check if this package should be curated
                if (tags.Any(tag => RequiredTags.Contains(tag, StringComparer.OrdinalIgnoreCase)))
                {
                    // It should!
                    // But now we need to ensure that the package's dependencies are also curated
                    if (DependenciesAreCurated(galleryPackage, feed))
                    {
                        await CuratedFeedService.CreatedCuratedPackageAsync(
                            feed,
                            galleryPackage.PackageRegistration,
                            automaticallyCurated : true,
                            commitChanges : commitChanges);
                    }
                }
            }
        }
Example #2
0
        public override async Task CurateAsync(
            Package galleryPackage,
            PackageArchiveReader nugetPackage,
            bool commitChanges)
        {
            var shouldBeIncluded = ShouldCuratePackage(galleryPackage, nugetPackage);

            if (!shouldBeIncluded)
            {
                return;
            }

            var curatedFeed = CuratedFeedService.GetFeedByName("webmatrix", includePackages: true);

            if (curatedFeed == null)
            {
                return;
            }

            if (DependenciesAreCurated(galleryPackage, curatedFeed))
            {
                await CuratedFeedService.CreatedCuratedPackageAsync(
                    curatedFeed,
                    galleryPackage.PackageRegistration,
                    included : true,
                    automaticallyCurated : true,
                    commitChanges : commitChanges);
            }
        }
        public virtual async Task <ActionResult> PostCuratedPackages(
            string curatedFeedName,
            CreateCuratedPackageRequest request)
        {
            var curatedFeed = CuratedFeedService.GetFeedByName(curatedFeedName, includePackages: true);

            if (curatedFeed == null)
            {
                return(HttpNotFound());
            }

            if (curatedFeed.Managers.All(manager => manager.Username != User.Identity.Name))
            {
                return(new HttpStatusCodeResult(403));
            }

            if (!ModelState.IsValid)
            {
                ViewBag.CuratedFeedName = curatedFeed.Name;
                return(View("CreateCuratedPackageForm"));
            }

            var packageRegistration = EntitiesContext.PackageRegistrations
                                      .Where(pr => pr.Id == request.PackageId)
                                      .Include(pr => pr.Owners).FirstOrDefault();

            if (packageRegistration == null)
            {
                ModelState.AddModelError("PackageId", Strings.PackageWithIdDoesNotExist);
                ViewBag.CuratedFeedName = curatedFeed.Name;
                return(View("CreateCuratedPackageForm"));
            }

            if (curatedFeed.Packages.Any(cp => cp.PackageRegistration.Key == packageRegistration.Key))
            {
                ModelState.AddModelError("PackageId", Strings.PackageIsAlreadyCurated);
                ViewBag.CuratedFeedName = curatedFeed.Name;
                return(View("CreateCuratedPackageForm"));
            }

            await CuratedFeedService.CreatedCuratedPackageAsync(
                curatedFeed,
                packageRegistration,
                included : true,
                automaticallyCurated : false,
                notes : request.Notes);

            return(RedirectToRoute(RouteName.CuratedFeed, new { name = curatedFeed.Name }));
        }