Example #1
0
        RestMSDomain CreateFeed(string domainUri, string name)
        {
            gateway.Logger.DebugFormat("Creating the feed {0} on the RestMS server: {1}", name, gateway.Configuration.RestMS.Uri.AbsoluteUri);
            var client = gateway.Client();

            try
            {
                var response = client.SendAsync(gateway.CreateRequest(
                                                    domainUri, gateway.CreateEntityBody(
                                                        new RestMSFeed
                {
                    Name  = name,
                    Type  = "Default",
                    Title = name
                })
                                                    )
                                                )
                               .Result;

                response.EnsureSuccessStatusCode();
                return(gateway.ParseResponse <RestMSDomain>(response));
            }
            catch (AggregateException ae)
            {
                foreach (var exception in ae.Flatten().InnerExceptions)
                {
                    gateway.Logger.ErrorFormat("Threw exception adding Feed {0} to RestMS Server {1}", name, exception.Message);
                }

                throw new RestMSClientException(string.Format("Error adding the Feed {0} to the RestMS server, see log for details", name));
            }
        }
Example #2
0
        public RestMSPipe GetPipe()
        {
            /*TODO: Optimize this by using a repository approach with the repository checking for modification
             * through etag and serving existing version if not modified and grabbing new version if changed*/

            gateway.Logger.DebugFormat("Getting the pipe from the RestMS server: {0}", PipeUri);
            var client = gateway.Client();

            try
            {
                var response = client.GetAsync(PipeUri).Result;
                response.EnsureSuccessStatusCode();
                return(gateway.ParseResponse <RestMSPipe>(response));
            }
            catch (AggregateException ae)
            {
                foreach (var exception in ae.Flatten().InnerExceptions)
                {
                    gateway.Logger.ErrorFormat("Threw exception getting Pipe {0} from RestMS Server {1}", PipeUri, exception.Message);
                }

                throw new RestMSClientException(string.Format("Error retrieving the domain from the RestMS server, see log for details"));
            }
        }
Example #3
0
        /// <summary>
        /// Gets the default domain.
        /// </summary>
        /// <returns>RestMSDomain.</returns>
        /// <exception cref="RestMSClientException"></exception>
        public RestMSDomain GetDomain()
        {
            _logger.Value.DebugFormat("Getting the default domain from the RestMS server: {0}", _gateway.Configuration.RestMS.Uri.AbsoluteUri);

            try
            {
                var response = _gateway.Client().GetAsync(_gateway.Configuration.RestMS.Uri).Result;
                response.EnsureSuccessStatusCode();
                return(_gateway.ParseResponse <RestMSDomain>(response));
            }
            catch (AggregateException ae)
            {
                foreach (var exception in ae.Flatten().InnerExceptions)
                {
                    _logger.Value.ErrorFormat("Threw exception getting Domain from RestMS Server {0}", exception.Message);
                }

                throw new RestMSClientException("Error retrieving the domain from the RestMS server, see log for details");
            }
        }
Example #4
0
        public RestMSJoin CreateJoin(string pipeUri, string routingKey)
        {
            _logger.Value.DebugFormat("Creating the join with key {0} for pipe {1}", routingKey, pipeUri);
            var client = _gateway.Client();

            try
            {
                var response = client.SendAsync(
                    _gateway.CreateRequest(
                        pipeUri,
                        _gateway.CreateEntityBody(
                            new RestMSJoin
                {
                    Address = routingKey,
                    Feed    = _feed.FeedUri,
                    Type    = "Default"
                }
                            )
                        )
                    )
                               .Result;

                response.EnsureSuccessStatusCode();
                var pipe = _gateway.ParseResponse <RestMSPipe>(response);
                return(pipe.Joins.FirstOrDefault());
            }
            catch (AggregateException ae)
            {
                foreach (var exception in ae.Flatten().InnerExceptions)
                {
                    _logger.Value.ErrorFormat("Threw exception adding join with routingKey {0} to Pipe {1} on RestMS Server {2}", routingKey, pipeUri, exception.Message);
                }

                throw new RestMSClientException(string.Format("Error adding the join with routingKey {0} to Pipe {1} to the RestMS server, see log for details", routingKey, pipeUri));
            }
        }