Esempio n. 1
0
        protected void GetCurrentAtomDocument()
        {
            var atomDocument = new AtomDocument(Title, Author, FeedId, DocumentId, LaterEventsDocumentId, Entries);

            atomDocument.AddDocumentInformation(Cluster.Get(Context.System).SelfAddress.ToString());
            Sender.Tell(atomDocument, Self);
        }
Esempio n. 2
0
        public async Task <HttpResponseMessage> GetFeed([FromUri] string subscriptionId)
        {
            var          subscription = new SubscriptionId(subscriptionId);
            AtomDocument document     = await atomDocumentRetriever.GetHeadDocument(subscription);

            return(SerialiseDocumentToResonse(document));
        }
Esempio n. 3
0
        private static HttpResponseMessage SerialiseDocumentToResonse(AtomDocument document)
        {
            var serialiser = new AtomDocumentSerialiser();
            var content    = new StringContent(serialiser.Serialise(document, "http://localhost:3600/events/atom/document/"),
                                               Encoding.UTF8, "application/atom+xml");
            var response = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = content
            };

            return(response);
        }
Esempio n. 4
0
        public Task <AtomDocument> GetDocument(string documentId)
        {
            List <AtomEntry> atomEntries = new List <AtomEntry>();

            if (entries.ContainsKey(documentId))
            {
                atomEntries = entries[documentId];
            }

            var document = new AtomDocument("", "", new FeedId(""), new DocumentId(documentId), new DocumentId(documentId), atomEntries);

            return(Task.FromResult(document));
        }
Esempio n. 5
0
        public async Task <AtomDocument> GetDocument(string documentId)
        {
            var results = await repo.GetAll(documentId, ConsistencyLevel.One);

            List <AtomEntry> atomEntries = new List <AtomEntry>();

            foreach (var result in results)
            {
                atomEntries.Add((AtomEntry)result);
            }
            var document = new AtomDocument("", "", new FeedId(""), new DocumentId(documentId), new DocumentId(documentId), atomEntries);

            return(document);
        }
        public string Serialise(AtomDocument feed, string baseUrl)
        {
            string data = @"<?xml version=""1.0"" encoding=""utf-8""?><feed xmlns=""http://www.w3.org/2005/Atom"">";

            data += @"<Title>" + feed.Title + @"</Title>";

            if (feed.DocumentId != null)
            {
                data += @"<link rel=""self"" type =""application/atom+xml"" href=""" + baseUrl + feed.DocumentId.Id + @"""/>";
            }

            if (feed.PreviousArchiveDocumentId != null && !string.IsNullOrEmpty(feed.PreviousArchiveDocumentId.Id))
            {
                data += @"<link rel=""prev-archive"" type =""application/atom+xml"" href =""" + baseUrl + feed.PreviousArchiveDocumentId.Id + @""" />";
            }

            if (feed.NextArchiveDocumentId != null && !string.IsNullOrEmpty(feed.NextArchiveDocumentId.Id))
            {
                data += @"<link rel=""next-archive"" type =""application/atom+xml"" href =""" + baseUrl + feed.NextArchiveDocumentId.Id + @""" />";
            }

            data += @"<Updated>" + feed.Updated.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'") + "</Updated>";
            data += @"<Author><name>" + feed.Author + "</name></Author>";
            data += @"<id>urn:uuid:" + feed.DocumentId.Id + "</id>";

            data += @"<documentInformation>" + feed.DocumentInformation + "</documentInformation>";


            foreach (var atomEntry in feed.Entries)
            {
                data += "<entry>";
                data += "<Title>" + atomEntry.Title + "</Title>";
                data += "<id>urn:uuid:" + atomEntry.Id + "</id>";
                data += "<Updated>" + atomEntry.Updated.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'") + "</Updated>";
                data += @"<content type=""application/json"">" + atomEntry.Content + "</content>";
                data += "</entry>";
            }
            data += "</feed>";

            return(data);
        }
 protected void GetCurrentAtomDocument()
 {
     var atomDocument = new AtomDocument(Title, Author, FeedId, DocumentId, LaterEventsDocumentId, Entries);
     atomDocument.AddDocumentInformation(Cluster.Get(Context.System).SelfAddress.ToString());
     Sender.Tell(atomDocument, Self);
 }
Esempio n. 8
0
        public async Task <HttpResponseMessage> GetDocument([FromUri] string documentId)
        {
            AtomDocument document = await atomDocumentRetriever.GetDocument(new DocumentId(documentId));

            return(SerialiseDocumentToResonse(document));
        }