Ejemplo n.º 1
0
        public SecurityPage([NotNull] FeedBuilder feedBuilder, [NotNull] IOpenPgp openPgp)
        {
            InitializeComponent();

            _feedBuilder = feedBuilder;
            _openPgp     = openPgp;
        }
Ejemplo n.º 2
0
        private HttpResponseMessage Search(string key, int page)
        {
            var searchResults = this.service.GetSearchResults(key, page);

            if (searchResults == null)
            {
                this.service.CreateSearch(key.ToSearch <TContract>());
                searchResults = this.service.GetSearchResults(key, page);
            }
            if (searchResults == null)
            {
                throw new NotFoundException(string.Format("Search results not found for key {0}/{1}", key, page));
            }

            var feedBuilder = new FeedBuilder()
                              .WithEntityName(this.entityName)
                              .WithId("search")
                              .WithTitle("Search Results")
                              .WithItemTitle(this.entityName)
                              .WithItems(searchResults.Contracts);

            if (searchResults.NextPage.HasValue)
            {
                feedBuilder.AddMoreResultsLink(this.Request.RequestUri, searchResults.SearchResultsKey, searchResults.NextPage);
            }

            var feed = feedBuilder.Build();

            return(this.Request.CreateResponse(HttpStatusCode.OK, feed, new AtomSyndicationFeedFormatter(), "application/xml"));
        }
Ejemplo n.º 3
0
        public ArchiveExtractPage([NotNull] FeedBuilder feedBuilder, [CanBeNull] InstallerCapture installerCapture = null)
        {
            InitializeComponent();

            _feedBuilder      = feedBuilder;
            _installerCapture = installerCapture;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Enables processing of the result of an action method by a custom type that inherits from the <see cref="T:System.Web.Mvc.ActionResult"/> class.
        /// </summary>
        /// <param name="context">The context in which the result is executed. The context information includes the controller, HTTP content, request context, and route data.</param>
        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = "application/rss+xml";
            string format = string.IsNullOrEmpty(Format) ? "rss" : Format.ToLower();

            FeedBuilder.Build(Feed, context.HttpContext.Response.Output, format);
        }
Ejemplo n.º 5
0
        public DownloadPage([NotNull] FeedBuilder feedBuilder, [NotNull] InstallerCapture installerCapture)
        {
            InitializeComponent();

            _feedBuilder      = feedBuilder;
            _installerCapture = installerCapture;
        }
Ejemplo n.º 6
0
        public InstallerCaptureDiffPage([NotNull] InstallerCapture installerCapture, [NotNull] FeedBuilder feedBuilder)
        {
            InitializeComponent();

            _installerCapture = installerCapture;
            _feedBuilder      = feedBuilder;
        }
        /// <summary>
        /// Returns a list of the entities as an Atom XML feed
        /// </summary>
        /// <returns>Reponse with appropriate status code and the Atom XML feed as content</returns>
        public HttpResponseMessage Get()
        {
            return(WebHandler(() =>
            {
                List <TContract> list;

                using (var scope = new TransactionScope(TransactionScopeOption.Required, ReadOptions()))
                {
                    // TODO: Constrain the identifiers we retrieve or have an enum to allow this e.g. Nexus, Originating, Default, All
                    list = new List <TContract>(this.service.List());
                    scope.Complete();
                }

                var entityName = typeof(TContract).Name.ToLowerInvariant();

                var feed = new FeedBuilder()
                           .WithEntityName(entityName)
                           .WithId("list")
                           .WithTitle("All")
                           .WithItemTitle(entityName)
                           .WithItems(list)
                           .Build();

                return this.Request.CreateResponse(HttpStatusCode.OK, feed, new AtomSyndicationFeedFormatter(),
                                                   "application/xml");
            }));
        }
Ejemplo n.º 8
0
        public FeedBuilderTests()
        {
            _config = new TestConfiguration();
            _builder = new FeedBuilder(_config);

            _config.Title = "Rosanna";
            _config.Url = "http://example.com";
            _config.Author = "Author";

            _feed = _builder.GetFeed(new ArticleRepository(_config, new PathResolver(_config)).GetArticles());
        }
Ejemplo n.º 9
0
        public static CaptureSession Start([NotNull] FeedBuilder feedBuilder)
        {
            #region Sanity checks
            if (feedBuilder == null)
            {
                throw new ArgumentNullException("feedBuilder");
            }
            #endregion

            return(new CaptureSession(Snapshot.Take(), feedBuilder));
        }
Ejemplo n.º 10
0
        public static CaptureSession Load([NotNull] string path, [NotNull] FeedBuilder feedBuilder)
        {
            #region Sanity checks
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path");
            }
            if (feedBuilder == null)
            {
                throw new ArgumentNullException("feedBuilder");
            }
            #endregion

            return(new CaptureSession(BinaryStorage.LoadBinary <Snapshot>(path), feedBuilder));
        }
Ejemplo n.º 11
0
        public SyndicationFeed LoadFeed()
        {
            var syndicationItems = _assemblies
                                   .SelectMany(LoadSyndicationItemsFromAssembly)
                                   .OrderByDescending(p => p.PublishDate)
                                   .ToArray();

            var feed = new FeedBuilder().Build(_feedSettings, syndicationItems);

            foreach (var item in syndicationItems)
            {
                item.SourceFeed = feed;
            }

            return(feed);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Tries extracting the installer as an <see cref="Archive"/>.
        /// </summary>
        /// <param name="feedBuilder">All collected data is stored into this builder.</param>
        /// <param name="handler">A callback object used when the the user is to be informed about progress.</param>
        /// <exception cref="OperationCanceledException">The user canceled the task.</exception>
        /// <exception cref="IOException">The installer could not be extracted as an archive.</exception>
        /// <exception cref="UnauthorizedAccessException">Read or write access to a temporary file is not permitted.</exception>
        public void ExtractInstallerAsArchive(FeedBuilder feedBuilder, ITaskHandler handler)
        {
            if (string.IsNullOrEmpty(_localPath) || _url == null)
            {
                throw new InvalidOperationException();
            }

            var archive = new Archive
            {
                Href     = _url,
                MimeType = _localPath.EndsWith(@".msi")
                    ? Archive.MimeTypeMsi
                           // 7zip's extraction logic can handle a number of self-extracting formats
                    : Archive.MimeType7Z
            };

            feedBuilder.RetrievalMethod    = archive;
            feedBuilder.TemporaryDirectory = archive.ToTempDir(handler, _localPath);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Convert this to a feed.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="author"></param>
        /// <param name="description"></param>
        /// <param name="title"></param>
        /// <param name="uri">The uri of the request</param>
        public static SyndicationFeed AsFeed <T>(Uri uri, string author, string title, string description)
        {
            IEntityService <T>   service = EntityRegistration.GetService <T>();
            IList <IPublishable> entries = service.GetRecentAs <IPublishable>(1, 20);
            //http://localhost:49739/Post/rss/

            string host = uri.Host;

            if (host.Contains("localhost"))
            {
                host = "http://localhost.com";
            }
            else
            {
                host = uri.AbsoluteUri;
            }
            var feed = FeedBuilder.Build(author, title, description, host, entries);

            return(feed);
        }
Ejemplo n.º 14
0
        private ExitCode Finish()
        {
            if (_additionalArgs.Count != 3)
            {
                return(PrintHelp());
            }
            string snapshotFile = _additionalArgs[1];
            string feedFile     = _additionalArgs[2];

            if (FileExists(feedFile))
            {
                return(ExitCode.IOError);
            }

            var feedBuilder = new FeedBuilder();
            var session     = CaptureSession.Load(snapshotFile, feedBuilder);

            session.InstallationDir = _installationDirectory;
            session.Diff(_handler);

            feedBuilder.MainCandidate = string.IsNullOrEmpty(_mainExe)
                ? feedBuilder.Candidates.FirstOrDefault()
                : feedBuilder.Candidates.FirstOrDefault(x => StringUtils.EqualsIgnoreCase(FileUtils.UnifySlashes(x.RelativePath), _mainExe));
            session.Finish();

            if (!string.IsNullOrEmpty(_zipFile))
            {
                if (FileExists(_zipFile))
                {
                    return(ExitCode.IOError);
                }

                var relativeUri = new Uri(Path.GetFullPath(feedFile)).MakeRelativeUri(new Uri(Path.GetFullPath(_zipFile)));
                session.CollectFiles(_zipFile, relativeUri, _handler);
                Log.Warn("If you wish to upload this feed and ZIP archive, make sure to turn the <archive>'s relative href into an absolute one.");
            }

            feedBuilder.Build().Save(feedFile);

            return(ExitCode.OK);
        }
        /// <summary>
        /// Returns all the mappings for the entity as an Atom XML feed
        /// </summary>
        /// <param name="id">The MDM identifier for the entity</param>
        /// <param name="etag">The current version held by the client</param>
        /// <returns>Response with approrpiate status code and the Atom feed as content</returns>
        public HttpResponseMessage Get(int id, [IfNoneMatch] ETag etag)
        {
            return(WebHandler(() =>
            {
                var request = MessageFactory.GetRequest(QueryParameters);
                request.EntityId = id;
                request.Version = etag.ToVersion();

                ContractResponse <TContract> response;

                using (var scope = new TransactionScope(TransactionScopeOption.Required, ReadOptions()))
                {
                    response = service.Request(request);
                    scope.Complete();
                }

                if (!response.IsValid)
                {
                    throw new MdmFaultException(new GetRequestFaultHandler().Create(typeof(TContract).Name,
                                                                                    response.Error, request));
                }

                var entityName = typeof(TContract).Name.ToLowerInvariant();
                var title = string.Format("Mappings for {0} {1} ", entityName, id);
                var feed = new FeedBuilder()
                           .WithEntityName(entityName)
                           .WithId(id.ToString())
                           .WithTitle(title)
                           .WithItemTitle("mapping")
                           .WithItems(response.Contract.Identifiers)
                           .Build();

                return Request.CreateResponse(HttpStatusCode.OK, feed, new AtomSyndicationFeedFormatter(),
                                              "application/xml");
            }));
        }
Ejemplo n.º 16
0
        private ExitCode Finish()
        {
            if (_additionalArgs.Count != 3) return PrintHelp();
            string snapshotFile = _additionalArgs[1];
            string feedFile = _additionalArgs[2];
            if (FileExists(feedFile)) return ExitCode.IOError;

            var feedBuilder = new FeedBuilder();
            var session = CaptureSession.Load(snapshotFile, feedBuilder);

            session.InstallationDir = _installationDirectory;
            session.Diff(_handler);

            feedBuilder.MainCandidate = string.IsNullOrEmpty(_mainExe)
                ? feedBuilder.Candidates.FirstOrDefault()
                : feedBuilder.Candidates.FirstOrDefault(x => StringUtils.EqualsIgnoreCase(FileUtils.UnifySlashes(x.RelativePath), _mainExe));
            session.Finish();

            if (!string.IsNullOrEmpty(_zipFile))
            {
                if (FileExists(_zipFile)) return ExitCode.IOError;

                var relativeUri = new Uri(Path.GetFullPath(feedFile)).MakeRelativeUri(new Uri(Path.GetFullPath(_zipFile)));
                session.CollectFiles(_zipFile, relativeUri, _handler);
                Log.Warn("If you wish to upload this feed and ZIP archive, make sure to turn the <archive>'s relative href into an absolute one.");
            }

            feedBuilder.Build().Save(feedFile);

            return ExitCode.OK;
        }
Ejemplo n.º 17
0
        static void Main(string[] args)
        {
            FeedBuilder fb = new FeedBuilder();

            fb.Build();
        }
Ejemplo n.º 18
0
 public FeedCooker(FeedBuilder feedBuilder)
 {
     _feedBuilder = feedBuilder;
 }
Ejemplo n.º 19
0
 private CaptureSession([NotNull] Snapshot snapshotBefore, [NotNull] FeedBuilder feedBuilder)
 {
     _snapshot = snapshotBefore;
     _feedBuilder = feedBuilder;
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Captures the current system state as a snapshot of the system state before the target application was installed.
 /// </summary>
 /// <param name="feedBuilder">All collected data is stored into this builder. You can perform additional modifications before using <see cref="FeedBuilder.Build"/> to get a feed.</param>
 /// <exception cref="IOException">There was an error accessing the registry or file system.</exception>
 /// <exception cref="UnauthorizedAccessException">Access to the registry or the file system was not permitted.</exception>
 public static CaptureSession Start(FeedBuilder feedBuilder)
 => new(
Ejemplo n.º 21
0
        public EntryPointPage([NotNull] FeedBuilder feedBuilder)
        {
            InitializeComponent();

            _feedBuilder = feedBuilder;
        }
Ejemplo n.º 22
0
 private CaptureSession(Snapshot snapshotBefore, FeedBuilder feedBuilder)
 {
     _snapshot    = snapshotBefore;
     _feedBuilder = feedBuilder;
 }
Ejemplo n.º 23
0
 private CaptureSession([NotNull] Snapshot snapshotBefore, [NotNull] FeedBuilder feedBuilder)
 {
     _snapshot    = snapshotBefore;
     _feedBuilder = feedBuilder;
 }
Ejemplo n.º 24
0
        public DetailsPage([NotNull] FeedBuilder feedBuilder)
        {
            InitializeComponent();

            _feedBuilder = feedBuilder;
        }