public PackageCatalogItem(NupkgMetadata nupkgMetadata, DateTime? createdDate = null, DateTime? lastEditedDate = null, DateTime? publishedDate = null, string licenseNames = null, string licenseReportUrl = null)
 {
     _nupkgMetadata = nupkgMetadata;
     _createdDate = createdDate;
     _lastEditedDate = lastEditedDate;
     _publishedDate = publishedDate;
 }
Ejemplo n.º 2
0
 public static PackageCatalogItem CreateCatalogItem(
     string origin,
     Stream stream,
     DateTime createdDate,
     DateTime?lastEditedDate = null,
     DateTime?publishedDate  = null,
     string licenseNames     = null,
     string licenseReportUrl = null,
     string packageHash      = null,
     PackageDeprecationItem deprecationItem           = null,
     IList <PackageVulnerabilityItem> vulnerabilities = null)
 {
     try
     {
         NupkgMetadata nupkgMetadata = GetNupkgMetadata(stream, packageHash);
         return(new PackageCatalogItem(
                    nupkgMetadata,
                    createdDate,
                    lastEditedDate,
                    publishedDate,
                    deprecation: deprecationItem,
                    vulnerabilities: vulnerabilities));
     }
     catch (InvalidDataException e)
     {
         Trace.TraceError("Exception: {0} {1} {2}", origin, e.GetType().Name, e);
         return(null);
     }
     catch (Exception e)
     {
         throw new Exception(string.Format("Exception processsing {0}", origin), e);
     }
 }
 public PackageCatalogItem(NupkgMetadata nupkgMetadata, DateTime?createdDate = null, DateTime?lastEditedDate = null, DateTime?publishedDate = null, string licenseNames = null, string licenseReportUrl = null)
 {
     NupkgMetadata  = nupkgMetadata;
     CreatedDate    = createdDate;
     LastEditedDate = lastEditedDate;
     PublishedDate  = publishedDate;
 }
Ejemplo n.º 4
0
 public PackageCatalogItem(
     NupkgMetadata nupkgMetadata,
     DateTime?createdDate               = null,
     DateTime?lastEditedDate            = null,
     DateTime?publishedDate             = null,
     string licenseNames                = null,
     string licenseReportUrl            = null,
     PackageDeprecationItem deprecation = null,
     IList <PackageVulnerabilityItem> vulnerabilities = null)
 {
     NupkgMetadata   = nupkgMetadata;
     CreatedDate     = createdDate;
     LastEditedDate  = lastEditedDate;
     PublishedDate   = publishedDate;
     Deprecation     = deprecation;
     Vulnerabilities = vulnerabilities;
 }
Ejemplo n.º 5
0
        public async Task Load(string path, CancellationToken cancellationToken)
        {
            var directoryInfo = new DirectoryInfo(path);

            foreach (var fileInfo in directoryInfo.EnumerateFiles("*.nuspec"))
            {
                AddNuspec(fileInfo);
            }

            //  Catalog

            var factory = new MemoryStorageFactory(new Uri(_baseAddress, Catalog), _store);
            var storage = factory.Create();

            var catalog = new AppendOnlyCatalogWriter(storage);

            foreach (var registration in Data.Values)
            {
                foreach (var package in registration.Values)
                {
                    var metadata = new NupkgMetadata
                    {
                        Nuspec = package
                    };
                    catalog.Add(new PackageCatalogItem(metadata));
                }
            }

            await catalog.Commit(null, cancellationToken);

            Uri catalogIndex = new Uri(storage.BaseAddress, "index.json");

            Func<StorageHttpMessageHandler> handlerFunc = () => { return new StorageHttpMessageHandler(storage); };

            await CreateRegistrationBlobs(catalogIndex, handlerFunc, cancellationToken);
            await CreateFlatContainer(catalogIndex, handlerFunc, cancellationToken);
            await CreateLuceneIndex(catalogIndex, handlerFunc, cancellationToken);
            await CreateIndex(cancellationToken);
        }