Ejemplo n.º 1
0
        public static Stream GetZipArchiveEntry(PipelinePackage package, PackagePipelineContext context, string entryName)
        {
            ZipArchive      zipArchive = GetZipArchive(package, context);
            ZipArchiveEntry entry      = zipArchive.GetEntry(entryName);

            return(entry.Open());
        }
Ejemplo n.º 2
0
 public static XDocument GetXmlZipArchiveEntry(PipelinePackage package, PackagePipelineContext context, string entryName)
 {
     using (Stream stream = GetZipArchiveEntry(package, context, entryName))
     {
         return(XDocument.Load(stream));
     }
 }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            DateTime?commitTimeStamp = PackagePipelineHelpers.GetCommitTimeStamp(context);
            Guid?    commitId        = PackagePipelineHelpers.GetCommitId(context);

            IGraph graph = new Graph();

            INode resource = graph.CreateUriNode(context.Uri);

            if (commitTimeStamp != null)
            {
                graph.Assert(
                    resource,
                    graph.CreateUriNode(Schema.Predicates.CatalogTimeStamp),
                    graph.CreateLiteralNode(commitTimeStamp.Value.ToString("O"), Schema.DataTypes.DateTime));
            }

            if (commitId != null)
            {
                graph.Assert(
                    resource,
                    graph.CreateUriNode(Schema.Predicates.CatalogCommitId),
                    graph.CreateLiteralNode(commitId.Value.ToString()));
            }

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return(true);
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            DateTime? commitTimeStamp = PackagePipelineHelpers.GetCommitTimeStamp(context);
            Guid? commitId = PackagePipelineHelpers.GetCommitId(context);

            IGraph graph = new Graph();

            INode resource = graph.CreateUriNode(context.Uri);

            if (commitTimeStamp != null)
            {
                graph.Assert(
                    resource,
                    graph.CreateUriNode(Schema.Predicates.CatalogTimeStamp),
                    graph.CreateLiteralNode(commitTimeStamp.Value.ToString("O"), Schema.DataTypes.DateTime));
            }

            if (commitId != null)
            {
                graph.Assert(
                    resource,
                    graph.CreateUriNode(Schema.Predicates.CatalogCommitId),
                    graph.CreateLiteralNode(commitId.Value.ToString()));
            }

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return true;
        }
 public static XDocument GetXmlZipArchiveEntry(PipelinePackage package, PackagePipelineContext context, string entryName)
 {
     using (Stream stream = GetZipArchiveEntry(package, context, entryName))
     {
         return XDocument.Load(stream);
     }
 }
Ejemplo n.º 6
0
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            XDocument document = PackagePipelineHelpers.GetXmlZipArchiveEntry(package, context, _entryName);



            return(true);
        }
Ejemplo n.º 7
0
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            XDocument document = PackagePipelineHelpers.GetXmlZipArchiveEntry(package, context, _entryName);



            return true;
        }
Ejemplo n.º 8
0
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            JToken packageSpec = PackagePipelineHelpers.GetPackageSpec(package, context);

            JToken token = PackagePipelineHelpers.GetContext("");

            Console.WriteLine(token);

            return(true);
        }
 public override bool Execute(PipelinePackage package, PackagePipelineContext context)
 {
     JToken packageSpec = PackagePipelineHelpers.GetPackageSpec(package, context);
     string id = packageSpec["id"].ToString();
     string version = packageSpec["version"].ToString();
     string relativeAddress = string.Format("{0}/{1}", id, version);
     context.Uri = new Uri(context.BaseAddress, relativeAddress.ToLowerInvariant());
     packageSpec["@id"] = context.Uri.AbsoluteUri;
     return true;
 }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            JToken packageSpec = PackagePipelineHelpers.GetPackageSpec(package, context);

            JToken token = PackagePipelineHelpers.GetContext("");

            Console.WriteLine(token);

            return true;
        }
Ejemplo n.º 11
0
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            JToken packageSpec     = PackagePipelineHelpers.GetPackageSpec(package, context);
            string id              = packageSpec["id"].ToString();
            string version         = packageSpec["version"].ToString();
            string relativeAddress = string.Format("{0}/{1}", id, version);

            context.Uri        = new Uri(context.BaseAddress, relativeAddress.ToLowerInvariant());
            packageSpec["@id"] = context.Uri.AbsoluteUri;
            return(true);
        }
 public static DateTime? GetCommitTimeStamp(PackagePipelineContext context)
 {
     object obj;
     if (context.Shelf.TryGetValue(PackagePipelinePropertyNames.CommitTimeStampPropertyName, out obj))
     {
         return (DateTime)obj;
     }
     else
     {
         return null;
     }
 }
 public static Guid? GetCommitId(PackagePipelineContext context)
 {
     object obj;
     if (context.Shelf.TryGetValue(PackagePipelinePropertyNames.CommitIdPropertyName, out obj))
     {
         return (Guid)obj;
     }
     else
     {
         return null;
     }
 }
Ejemplo n.º 14
0
        public static Guid?GetCommitId(PackagePipelineContext context)
        {
            object obj;

            if (context.Shelf.TryGetValue(PackagePipelinePropertyNames.CommitIdPropertyName, out obj))
            {
                return((Guid)obj);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 15
0
        public static DateTime?GetCommitTimeStamp(PackagePipelineContext context)
        {
            object obj;

            if (context.Shelf.TryGetValue(PackagePipelinePropertyNames.CommitTimeStampPropertyName, out obj))
            {
                return((DateTime)obj);
            }
            else
            {
                return(null);
            }
        }
 public static ZipArchive GetZipArchive(PipelinePackage package, PackagePipelineContext context)
 {
     object obj;
     if (context.Shelf.TryGetValue(PackagePipelinePropertyNames.ZipArchivePropertyName, out obj))
     {
         return (ZipArchive)obj;
     }
     else
     {
         ZipArchive zipArchive = new ZipArchive(package.Stream, ZipArchiveMode.Read, true);
         context.Shelf.Add(PackagePipelinePropertyNames.ZipArchivePropertyName, zipArchive);
         return zipArchive;
     }
 }
        public override StorageContent CreateContent(CatalogContext context)
        {
            PackagePipelineContext pipelineContext = new PackagePipelineContext(GetBaseAddress());

            _pipeline.Execute(_pipelinePackage, pipelineContext);

            _pageContent = ((GraphPackageMetadata)pipelineContext.PageResult).Graph;

            _itemAddress = pipelineContext.Uri;

            JObject frame = context.GetJsonLdContext("context.PackageDetails.json", Schema.DataTypes.PackageDetails);
            string json = pipelineContext.Result.ToContent(frame).ToString();

            return new StringStorageContent(json, "application/json", "no-store");
        }
Ejemplo n.º 18
0
        public override StorageContent CreateContent(CatalogContext context)
        {
            PackagePipelineContext pipelineContext = new PackagePipelineContext(GetBaseAddress());

            _pipeline.Execute(_pipelinePackage, pipelineContext);

            _pageContent = ((GraphPackageMetadata)pipelineContext.PageResult).Graph;

            _itemAddress = pipelineContext.Uri;

            JObject frame = context.GetJsonLdContext("context.PackageDetails.json", Schema.DataTypes.PackageDetails);
            string  json  = pipelineContext.Result.ToContent(frame).ToString();

            return(new StringStorageContent(json, "application/json", "no-store"));
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            string hash = GetHash(package.Stream);
            long size = GetSize(package.Stream);

            IGraph graph = new Graph();
            INode subject = graph.CreateUriNode(context.Uri);
            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.PackageHashAlgorithm), graph.CreateLiteralNode("SHA512"));
            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.PackageHash), graph.CreateLiteralNode(hash));
            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.PackageSize), graph.CreateLiteralNode(size.ToString(), Schema.DataTypes.Integer));

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return true;
        }
 public static XDocument GetNuspec(PipelinePackage package, PackagePipelineContext context)
 {
     object obj;
     if (context.Shelf.TryGetValue(PackagePipelinePropertyNames.NuspecPropertyName, out obj))
     {
         return (XDocument)obj;
     }
     else
     {
         ZipArchive zipArchive = GetZipArchive(package, context);
         XDocument nuspec = Utils.GetNuspec(zipArchive);
         context.Shelf.Add(PackagePipelinePropertyNames.NuspecPropertyName, nuspec);
         return nuspec;
     }
 }
Ejemplo n.º 21
0
        public static ZipArchive GetZipArchive(PipelinePackage package, PackagePipelineContext context)
        {
            object obj;

            if (context.Shelf.TryGetValue(PackagePipelinePropertyNames.ZipArchivePropertyName, out obj))
            {
                return((ZipArchive)obj);
            }
            else
            {
                ZipArchive zipArchive = new ZipArchive(package.Stream, ZipArchiveMode.Read, true);
                context.Shelf.Add(PackagePipelinePropertyNames.ZipArchivePropertyName, zipArchive);
                return(zipArchive);
            }
        }
Ejemplo n.º 22
0
        public static XDocument GetNuspec(PipelinePackage package, PackagePipelineContext context)
        {
            object obj;

            if (context.Shelf.TryGetValue(PackagePipelinePropertyNames.NuspecPropertyName, out obj))
            {
                return((XDocument)obj);
            }
            else
            {
                ZipArchive zipArchive = GetZipArchive(package, context);
                XDocument  nuspec     = Utils.GetNuspec(zipArchive);
                context.Shelf.Add(PackagePipelinePropertyNames.NuspecPropertyName, nuspec);
                return(nuspec);
            }
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            string hash = GetHash(package.Stream);
            long   size = GetSize(package.Stream);

            IGraph graph   = new Graph();
            INode  subject = graph.CreateUriNode(context.Uri);

            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.PackageHashAlgorithm), graph.CreateLiteralNode("SHA512"));
            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.PackageHash), graph.CreateLiteralNode(hash));
            graph.Assert(subject, graph.CreateUriNode(Schema.Predicates.PackageSize), graph.CreateLiteralNode(size.ToString(), Schema.DataTypes.Integer));

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return(true);
        }
        public static void Test0()
        {
            PackagePipeline pipeline = PackagePipelineFactory.Create2();

            Stream stream = new FileStream(@"C:\data\ema\nupkgs\BasicAppPackage.1.0.0.nupkg", FileMode.Open);

            PipelinePackage package = new PipelinePackage(stream);

            PackagePipelineContext context = new PackagePipelineContext(new Uri("http://azure.com/siena/package"));

            pipeline.Execute(package, context);

            PackageMetadataBase result = context.Result;

            Console.WriteLine(result.ToContent());
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            XDocument nuspec = PackagePipelineHelpers.GetNuspec(package, context);

            IGraph graph = Utils.CreateNuspecGraph(nuspec, context.BaseAddress.AbsoluteUri);

            INode rdfTypePredicate = graph.CreateUriNode(Schema.Predicates.Type);

            Triple resource = graph.GetTriplesWithPredicateObject(rdfTypePredicate, graph.CreateUriNode(Schema.DataTypes.PackageDetails)).First();
            graph.Assert(resource.Subject, rdfTypePredicate, graph.CreateUriNode(Schema.DataTypes.Permalink));

            IGraph pageGraph = CreatePageGraph(resource.Subject, graph);

            context.Uri = ((UriNode)resource.Subject).Uri;

            context.StageResults.Add(new GraphPackageMetadata(graph));

            context.StagePageResults.Add(new GraphPackageMetadata(pageGraph));

            return true;
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            ZipArchive zipArchive = PackagePipelineHelpers.GetZipArchive(package, context);

            IEnumerable<PackageEntry> entries = GetEntries(zipArchive);

            IGraph graph = new Graph();

            if (entries != null)
            {
                INode packageEntryPredicate = graph.CreateUriNode(Schema.Predicates.PackageEntry);
                INode packageEntryType = graph.CreateUriNode(Schema.DataTypes.PackageEntry);
                INode fullNamePredicate = graph.CreateUriNode(Schema.Predicates.FullName);
                INode namePredicate = graph.CreateUriNode(Schema.Predicates.Name);
                INode lengthPredicate = graph.CreateUriNode(Schema.Predicates.Length);
                INode compressedLengthPredicate = graph.CreateUriNode(Schema.Predicates.CompressedLength);
                INode rdfTypePredicate = graph.CreateUriNode(Schema.Predicates.Type);

                INode resource = graph.CreateUriNode(context.Uri);

                foreach (PackageEntry entry in entries)
                {
                    Uri entryUri = new Uri(context.Uri.AbsoluteUri + "#" + entry.FullName);

                    INode entryNode = graph.CreateUriNode(entryUri);

                    graph.Assert(resource, packageEntryPredicate, entryNode);
                    graph.Assert(entryNode, rdfTypePredicate, packageEntryType);
                    graph.Assert(entryNode, fullNamePredicate, graph.CreateLiteralNode(entry.FullName));
                    graph.Assert(entryNode, namePredicate, graph.CreateLiteralNode(entry.Name));
                    graph.Assert(entryNode, lengthPredicate, graph.CreateLiteralNode(entry.Length.ToString(), Schema.DataTypes.Integer));
                    graph.Assert(entryNode, compressedLengthPredicate, graph.CreateLiteralNode(entry.CompressedLength.ToString(), Schema.DataTypes.Integer));
                }
            }

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return true;
        }
Ejemplo n.º 27
0
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            XDocument nuspec = PackagePipelineHelpers.GetNuspec(package, context);

            IGraph graph = Utils.CreateNuspecGraph(nuspec, context.BaseAddress.AbsoluteUri);

            INode rdfTypePredicate = graph.CreateUriNode(Schema.Predicates.Type);

            Triple resource = graph.GetTriplesWithPredicateObject(rdfTypePredicate, graph.CreateUriNode(Schema.DataTypes.PackageDetails)).First();

            graph.Assert(resource.Subject, rdfTypePredicate, graph.CreateUriNode(Schema.DataTypes.Permalink));

            IGraph pageGraph = CreatePageGraph(resource.Subject, graph);

            context.Uri = ((UriNode)resource.Subject).Uri;

            context.StageResults.Add(new GraphPackageMetadata(graph));

            context.StagePageResults.Add(new GraphPackageMetadata(pageGraph));

            return(true);
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            ZipArchive zipArchive = PackagePipelineHelpers.GetZipArchive(package, context);

            IEnumerable <PackageEntry> entries = GetEntries(zipArchive);

            IGraph graph = new Graph();

            if (entries != null)
            {
                INode packageEntryPredicate     = graph.CreateUriNode(Schema.Predicates.PackageEntry);
                INode packageEntryType          = graph.CreateUriNode(Schema.DataTypes.PackageEntry);
                INode fullNamePredicate         = graph.CreateUriNode(Schema.Predicates.FullName);
                INode namePredicate             = graph.CreateUriNode(Schema.Predicates.Name);
                INode lengthPredicate           = graph.CreateUriNode(Schema.Predicates.Length);
                INode compressedLengthPredicate = graph.CreateUriNode(Schema.Predicates.CompressedLength);
                INode rdfTypePredicate          = graph.CreateUriNode(Schema.Predicates.Type);

                INode resource = graph.CreateUriNode(context.Uri);

                foreach (PackageEntry entry in entries)
                {
                    Uri entryUri = new Uri(context.Uri.AbsoluteUri + "#" + entry.FullName);

                    INode entryNode = graph.CreateUriNode(entryUri);

                    graph.Assert(resource, packageEntryPredicate, entryNode);
                    graph.Assert(entryNode, rdfTypePredicate, packageEntryType);
                    graph.Assert(entryNode, fullNamePredicate, graph.CreateLiteralNode(entry.FullName));
                    graph.Assert(entryNode, namePredicate, graph.CreateLiteralNode(entry.Name));
                    graph.Assert(entryNode, lengthPredicate, graph.CreateLiteralNode(entry.Length.ToString(), Schema.DataTypes.Integer));
                    graph.Assert(entryNode, compressedLengthPredicate, graph.CreateLiteralNode(entry.CompressedLength.ToString(), Schema.DataTypes.Integer));
                }
            }

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return(true);
        }
Ejemplo n.º 29
0
        public bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            if (!package.Stream.CanSeek)
            {
                throw new ArgumentException("package stream must be seekable");
            }

            bool f = true;

            foreach (PackagePipelineStage stage in _stages)
            {
                package.Stream.Seek(0, SeekOrigin.Begin);

                f = stage.Execute(package, context);
                if (!f)
                {
                    break;
                }
            }

            context.MergeStageResults();
            return(f);
        }
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            IGraph graph = new Graph();

            INode subject = graph.CreateUriNode(context.Uri);

            graph.Assert(
                subject,
                graph.CreateUriNode(Schema.Predicates.Published), 
                graph.CreateLiteralNode(package.Published.ToString("O"), Schema.DataTypes.DateTime));

            if (package.Owner != null)
            {
                graph.Assert(
                    subject,
                    graph.CreateUriNode(Schema.Predicates.Owner),
                    graph.CreateLiteralNode(package.Owner));
            }

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return true;
        }
Ejemplo n.º 31
0
        public override bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            IGraph graph = new Graph();

            INode subject = graph.CreateUriNode(context.Uri);

            graph.Assert(
                subject,
                graph.CreateUriNode(Schema.Predicates.Published),
                graph.CreateLiteralNode(package.Published.ToString("O"), Schema.DataTypes.DateTime));

            if (package.Owner != null)
            {
                graph.Assert(
                    subject,
                    graph.CreateUriNode(Schema.Predicates.Owner),
                    graph.CreateLiteralNode(package.Owner));
            }

            context.StageResults.Add(new GraphPackageMetadata(graph));

            return(true);
        }
        public bool Execute(PipelinePackage package, PackagePipelineContext context)
        {
            if (!package.Stream.CanSeek)
            {
                throw new ArgumentException("package stream must be seekable");
            }

            bool f = true;

            foreach (PackagePipelineStage stage in _stages)
            {
                package.Stream.Seek(0, SeekOrigin.Begin);

                f = stage.Execute(package, context);
                if (!f)
                {
                    break;
                }
            }

            context.MergeStageResults();
            return f;
        }
Ejemplo n.º 33
0
 public static void SetCommitTimeStamp(PackagePipelineContext context, DateTime commitTimeStamp)
 {
     context.Shelf[PackagePipelinePropertyNames.CommitTimeStampPropertyName] = commitTimeStamp;
 }
 public static void SetCommitId(PackagePipelineContext context, Guid commitId)
 {
     context.Shelf[PackagePipelinePropertyNames.CommitIdPropertyName] = commitId;
 }
 public static void SetCommitTimeStamp(PackagePipelineContext context, DateTime commitTimeStamp)
 {
     context.Shelf[PackagePipelinePropertyNames.CommitTimeStampPropertyName] = commitTimeStamp;
 }
Ejemplo n.º 36
0
 public static void SetCommitId(PackagePipelineContext context, Guid commitId)
 {
     context.Shelf[PackagePipelinePropertyNames.CommitIdPropertyName] = commitId;
 }
 public static Stream GetZipArchiveEntry(PipelinePackage package, PackagePipelineContext context, string entryName)
 {
     ZipArchive zipArchive = GetZipArchive(package, context);
     ZipArchiveEntry entry = zipArchive.GetEntry(entryName);
     return entry.Open();
 }