public static async Task<IList<string>> CheckRegistrationAuthorizationForEdit(IRegistrationOwnership registrationOwnership, PackageIdentity packageIdentity)
        {
            IList<string> errors = new List<string>();

            if (!await registrationOwnership.HasNamespace(packageIdentity.Namespace))
            {
                errors.Add("user is not allowed to publish in this namespace");
                return errors;
            }

            if (await registrationOwnership.HasRegistration(packageIdentity.Namespace, packageIdentity.Id))
            {
                if (!await registrationOwnership.HasOwner(packageIdentity.Namespace, packageIdentity.Id))
                {
                    errors.Add("user does not have access to this registration");
                    return errors;
                }
            }
            else
            {
                errors.Add("this package does not exist in the ownership record");
            }

            return errors;
        }
        public static async Task<IList<string>> CheckRegistrationAuthorization(IRegistrationOwnership registrationOwnership, PackageIdentity packageIdentity)
        {
            IList<string> errors = new List<string>();

            if (!await registrationOwnership.HasNamespace(packageIdentity.Namespace))
            {
                errors.Add("user is not allowed to publish in this namespace");
                return errors;
            }

            if (await registrationOwnership.HasRegistration(packageIdentity.Namespace, packageIdentity.Id))
            {
                if (!await registrationOwnership.HasOwner(packageIdentity.Namespace, packageIdentity.Id))
                {
                    errors.Add("user does not have access to this registration");
                    return errors;
                }

                if (await registrationOwnership.HasVersion(packageIdentity.Namespace, packageIdentity.Id, packageIdentity.Version.ToString()))
                {
                    errors.Add("this package version already exists for this registration");
                    return errors;
                }
            }

            return errors;
        }
        public DeleteCatalogItem(PackageIdentity packageIdentity, PublicationDetails publicationDetails)
        {
            _packageIdentity = packageIdentity;
            _publicationDetails = publicationDetails;

            _catalogItemId = Guid.NewGuid();

            _context = ServiceHelpers.LoadContext("context.catalog.json");
            _context["@type"] = GetItemType().AbsoluteUri;
        }
 async Task UpdateRegistrationOwnership(PackageIdentity packageIdentity)
 {
     await _registrationOwnership.AddVersion(packageIdentity.Namespace, packageIdentity.Id, packageIdentity.Version.ToString());
 }
 Task UpdateRegistrationOwnership(PackageIdentity packageIdentity)
 {
     //TODO: conditionally cleanup the package ownership record - we should be able to free up the id/version and possibly the id
     return Task.FromResult(0);
 }
 static Task<Uri> AddToCatalog(PackageIdentity packageIdentity, PublicationDetails publicationDetails, CancellationToken cancellationToken)
 {
     CatalogItem catalogItem = new DeleteCatalogItem(packageIdentity, publicationDetails);
     return CatalogHelpers.AddToCatalog(catalogItem, Configuration.StoragePrimary, Configuration.StorageContainerCatalog, Configuration.CatalogBaseAddress, cancellationToken);
 }