コード例 #1
0
ファイル: FeedManager.cs プロジェクト: Roblinde/GSA-Web-api
        /// <summary>
        /// Push the specified feed to the Google Search Appliance
        /// </summary>
        /// <param name="feed">The feed to push</param>
        /// <param name="async">Should the request to GSA be sent asynchronously</param>
        /// <returns>a <see cref="HttpStatusCode"/> that indicates whether the request succeded or failed</returns>
        /// <exception cref="ArgumentException">Thrown if you have not specified a correct host adress or feed</exception>
        public HttpStatusCode PushFeed(Feed feed, bool async = false)
        {
            if (string.IsNullOrEmpty(GsaHostAddress))
            {
                throw new ArgumentException("You have not specified a correct host address");
            }

            if (feed == null)
            {
                throw new ArgumentException("You must specify a feed", "feed");
            }

            var xml = feed.ConstructXml();

            if (FeedClient == null)
            {
                FeedClient = new FeedClient();
            }

            return FeedClient.PushFeed(xml, GsaHostAddress, async);
        }
コード例 #2
0
ファイル: FeedTests.cs プロジェクト: Roblinde/GSA-Web-api
        public void FeedShouldReturnCorrectXml()
        {
            var feed = new Feed();
            var record = new FeedRecord();
            record.Url = "http://www.sf.se/";

            feed.Records.Add(record);

            var xml = feed.ConstructXml();

            Assert.AreEqual("<!DOCTYPE gsafeed PUBLIC \"-//Google//DTD GSA Feeds//EN\" \"\"[]>\r\n<gsafeed>\r\n  <header>\r\n    <datasource>web</datasource>\r\n    <feedtype>incremental</feedtype>\r\n  </header>\r\n  <group>\r\n    <record url=\"http://www.sf.se/\" lock=\"false\" mimetype=\"requiredbutignored\" authmethod=\"none\" crawl-immediately=\"false\" crawl-once=\"false\" />\r\n  </group>\r\n</gsafeed>", xml);
        }