Exemple #1
0
        /// <summary>
        /// Asynchronous PUT to the server
        /// </summary>
        /// <param name="request">The request that identifies the resource within the syndication data source.</param>
        /// <param name="resource">The resource that should be created asynchronously.</param>
        public virtual AsyncRequest CreateAsync(SDataBaseRequest request, ISyndicationResource resource)
        {
            Guard.ArgumentNotNull(request, "request");
            Guard.ArgumentNotNull(resource, "resource");

            try
            {
                var url = new SDataUri(request.ToString())
                {
                    TrackingId = Guid.NewGuid().ToString()
                }.ToString();
                var operation = new RequestOperation(HttpMethod.Post, resource);
                var response  = ExecuteRequest(url, operation, MediaType.Xml);
                var tracking  = response.Content as Tracking;
                if (tracking == null)
                {
                    throw new SDataClientException("Unexpected content: " + response.Content);
                }
                return(new AsyncRequest(this, response.Location, tracking));
            }
            catch (SDataClientException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// Adds a new syndication resource to the data source.
        /// </summary>
        /// <param name="request">The request that identifies the resource within the syndication data source.</param>
        /// <param name="entry">The entry that should be created.</param>
        public virtual AtomEntry CreateEntry(SDataBaseRequest request, AtomEntry entry)
        {
            Guard.ArgumentNotNull(request, "request");
            var requestUrl = request.ToString();

            return(CreateEntry(requestUrl, entry));
        }
Exemple #3
0
        /// <summary>
        /// Adds a new syndication resource to the data source.
        /// </summary>
        /// <param name="request">The request that identifies the resource within the syndication data source.</param>
        /// <param name="entry">The entry that should be created.</param>
        public virtual AtomEntry CreateEntry(SDataBaseRequest request, AtomEntry entry)
        {
            Guard.ArgumentNotNull(request, "request");
            Guard.ArgumentNotNull(entry, "entry");

            try
            {
                var url       = request.ToString();
                var batchItem = new SDataBatchRequestItem
                {
                    Url    = url,
                    Method = HttpMethod.Post,
                    Entry  = entry
                };

                if (BatchProcess.Instance.AddToBatch(batchItem))
                {
                    return(null);
                }

                var operation = new RequestOperation(HttpMethod.Post, entry);
                return(ExecuteEntryRequest(url, operation));
            }
            catch (SDataClientException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
Exemple #4
0
        /// <summary>
        /// Removes a resource from the syndication data source.
        /// </summary>
        /// <param name="request">The request from the syndication data source for the resource to be removed.</param>
        /// <param name="entry">the resource that is being deleted</param>
        /// <returns><b>true</b> if the syndication resource was successfully deleted; otherwise, <b>false</b>.</returns>
        public virtual bool DeleteEntry(SDataBaseRequest request, AtomEntry entry)
        {
            Guard.ArgumentNotNull(request, "request");

            try
            {
                var url  = request.ToString();
                var eTag = entry != null?entry.GetSDataHttpETag() : null;

                var batchItem = new SDataBatchRequestItem
                {
                    Url    = url,
                    Method = HttpMethod.Delete,
                    ETag   = eTag
                };

                if (BatchProcess.Instance.AddToBatch(batchItem))
                {
                    return(true);
                }

                var operation = new RequestOperation(HttpMethod.Delete)
                {
                    ETag = eTag
                };
                var response = ExecuteRequest(url, operation, MediaType.AtomEntry, MediaType.Xml);
                return(response.StatusCode == HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
Exemple #5
0
        /// <summary>
        /// Adds a new syndication resource to the data source.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="feed"></param>
        /// <param name="eTag"></param>
        /// <returns></returns>
        public virtual AtomFeed CreateFeed(SDataBaseRequest request, AtomFeed feed, out string eTag)
        {
            Guard.ArgumentNotNull(request, "request");
            Guard.ArgumentNotNull(feed, "feed");

            try
            {
                var requestUrl = request.ToString();
                var operation  = new RequestOperation(HttpMethod.Post, feed);
                var response   = ExecuteRequest(requestUrl, operation, MediaType.Atom, MediaType.Xml);
                eTag = response.ETag;
                return((AtomFeed)response.Content);
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
Exemple #6
0
        /// <summary>
        /// Adds a new syndication resource to the data source.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="feed"></param>
        /// <param name="eTag"></param>
        /// <returns></returns>
        public virtual AtomFeed CreateFeed(SDataBaseRequest request, AtomFeed feed, out string eTag)
        {
            Guard.ArgumentNotNull(request, "request");
            Guard.ArgumentNotNull(feed, "feed");

            try
            {
                var url       = request.ToString();
                var operation = new RequestOperation(HttpMethod.Post, feed);
                return(ExecuteFeedRequest(url, operation, out eTag));
            }
            catch (SDataClientException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
Exemple #7
0
        /// <summary>
        /// Reads resource information from the data source based on the URL and the ETag of the specified entry.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="entry"></param>
        /// <returns></returns>
        public virtual AtomEntry ReadEntry(SDataBaseRequest request, AtomEntry entry)
        {
            Guard.ArgumentNotNull(request, "request");

            try
            {
                var requestUrl = request.ToString();
                var eTag       = entry != null?entry.GetSDataHttpETag() : null;

                var batchItem = new SDataBatchRequestItem
                {
                    Url    = requestUrl,
                    Method = HttpMethod.Get,
                    ETag   = eTag
                };

                if (BatchProcess.Instance.AddToBatch(batchItem))
                {
                    return(null);
                }

                var operation = new RequestOperation(HttpMethod.Get)
                {
                    ETag = eTag
                };
                var response = ExecuteRequest(requestUrl, operation, MediaType.AtomEntry, MediaType.Xml);
                entry = (AtomEntry)response.Content;

                if (!string.IsNullOrEmpty(response.ETag))
                {
                    entry.SetSDataHttpETag(response.ETag);
                }

                return(entry);
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
Exemple #8
0
        /// <summary>
        /// Reads resource information from the data source based on the URL and the specified ETag.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="eTag"></param>
        /// <returns></returns>
        public virtual AtomFeed ReadFeed(SDataBaseRequest request, ref string eTag)
        {
            Guard.ArgumentNotNull(request, "request");

            try
            {
                var url       = request.ToString();
                var operation = new RequestOperation(HttpMethod.Get)
                {
                    ETag = eTag
                };
                return(ExecuteFeedRequest(url, operation, out eTag));
            }
            catch (SDataClientException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
Exemple #9
0
        /// <summary>
        /// Reads resource information from the data source based on the URL and the ETag of the specified entry.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="entry"></param>
        /// <returns></returns>
        public virtual AtomEntry ReadEntry(SDataBaseRequest request, AtomEntry entry)
        {
            Guard.ArgumentNotNull(request, "request");

            try
            {
                var url  = request.ToString();
                var eTag = entry != null?entry.GetSDataHttpETag() : null;

                var batchItem = new SDataBatchRequestItem
                {
                    Url    = url,
                    Method = HttpMethod.Get,
                    ETag   = eTag
                };

                if (BatchProcess.Instance.AddToBatch(batchItem))
                {
                    return(null);
                }

                var operation = new RequestOperation(HttpMethod.Get)
                {
                    ETag = eTag
                };
                return(ExecuteEntryRequest(url, operation));
            }
            catch (SDataClientException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
 /// <summary>
 /// Reads resource information from the data source based on the URL.
 /// </summary>
 /// <param name="request">request for the syndication resource to get information for.</param>
 /// <returns>AtomFeed <see cref="AtomFeed"/> populated with the specified resources's information from the data source.</returns>
 public virtual AtomFeed ReadFeed(SDataBaseRequest request)
 {
     string eTag = null;
     return ReadFeed(request, ref eTag);
 }
 /// <summary>
 /// Reads resource information from the data source based on the URL.
 /// </summary>
 /// <param name="request">Request for the syndication resource to get information for.</param>
 /// <returns>An <see cref="AtomEntry"/> populated with the specified resources' information from the data source.</returns>
 public virtual AtomEntry ReadEntry(SDataBaseRequest request)
 {
     return ReadEntry(request, null);
 }
        /// <summary>
        /// Reads resource information from the data source based on the URL and the ETag of the specified entry.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="entry"></param>
        /// <returns></returns>
        public virtual AtomEntry ReadEntry(SDataBaseRequest request, AtomEntry entry)
        {
            Guard.ArgumentNotNull(request, "request");

            try
            {
                var requestUrl = request.ToString();
                var eTag = entry != null ? entry.GetSDataHttpETag() : null;
                var batchItem = new SDataBatchRequestItem
                                {
                                    Url = requestUrl,
                                    Method = HttpMethod.Get,
                                    ETag = eTag
                                };

                if (BatchProcess.Instance.AddToBatch(batchItem))
                {
                    return null;
                }

                var operation = new RequestOperation(HttpMethod.Get) {ETag = eTag};
                var response = ExecuteRequest(requestUrl, operation, MediaType.AtomEntry, MediaType.Xml);
                entry = (AtomEntry) response.Content;

                if (!string.IsNullOrEmpty(response.ETag))
                {
                    entry.SetSDataHttpETag(response.ETag);
                }

                return entry;
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
 /// <summary>
 /// Adds a new syndication resource to the data source.
 /// </summary>
 /// <param name="request">The request that identifies the resource within the syndication data source.</param>
 /// <param name="feed"></param>
 public virtual AtomFeed CreateFeed(SDataBaseRequest request, AtomFeed feed)
 {
     string eTag;
     return CreateFeed(request, feed, out eTag);
 }
 /// <summary>
 /// Removes a resource from the syndication data source.
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public virtual bool DeleteEntry(SDataBaseRequest request)
 {
     return DeleteEntry(request, null);
 }
Exemple #15
0
        /// <summary>
        /// Reads resource information from the data source based on the URL.
        /// </summary>
        /// <param name="request">request for the syndication resource to get information for.</param>
        /// <returns>AtomFeed <see cref="AtomFeed"/> populated with the specified resources's information from the data source.</returns>
        public virtual AtomFeed ReadFeed(SDataBaseRequest request)
        {
            string eTag = null;

            return(ReadFeed(request, ref eTag));
        }
 /// <summary>
 /// Adds a new syndication resource to the data source.
 /// </summary>
 /// <param name="request">The request that identifies the resource within the syndication data source.</param>
 /// <param name="entry">The entry that should be created.</param>
 public virtual AtomEntry CreateEntry(SDataBaseRequest request, AtomEntry entry)
 {
     Guard.ArgumentNotNull(request, "request");
     var requestUrl = request.ToString();
     return CreateEntry(requestUrl, entry);
 }
        /// <summary>
        /// Reads resource information from the data source based on the URL and the specified ETag.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="eTag"></param>
        /// <returns></returns>
        public virtual AtomFeed ReadFeed(SDataBaseRequest request, ref string eTag)
        {
            Guard.ArgumentNotNull(request, "request");

            try
            {
                var url = request.ToString();
                var operation = new RequestOperation(HttpMethod.Get) {ETag = eTag};
                return ExecuteFeedRequest(url, operation, out eTag);
            }
            catch (SDataClientException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
        /// <summary>
        /// Updates information about a syndication resource in the data source.
        /// </summary>
        /// <param name="request">The url from the syndication data source for the resource to be updated.</param>
        /// <param name="entry">
        ///     An object that implements the <see cref="ISyndicationResource"/> interface that represents the updated information for the resource.
        /// </param>
        public virtual AtomEntry UpdateEntry(SDataBaseRequest request, AtomEntry entry)
        {
            Guard.ArgumentNotNull(request, "request");
            Guard.ArgumentNotNull(entry, "entry");

            try
            {
                var url = request.ToString();
                var eTag = entry.GetSDataHttpETag();
                var batchItem = new SDataBatchRequestItem
                                {
                                    Url = url,
                                    Method = HttpMethod.Put,
                                    Entry = entry,
                                    ETag = eTag
                                };

                if (BatchProcess.Instance.AddToBatch(batchItem))
                {
                    return null;
                }

                var operation = new RequestOperation(HttpMethod.Put, entry) {ETag = eTag};
                return ExecuteEntryRequest(url, operation);
            }
            catch (SDataClientException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
        /// <summary>
        /// Adds a new syndication resource to the data source.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="feed"></param>
        /// <param name="eTag"></param>
        /// <returns></returns>
        public virtual AtomFeed CreateFeed(SDataBaseRequest request, AtomFeed feed, out string eTag)
        {
            Guard.ArgumentNotNull(request, "request");
            Guard.ArgumentNotNull(feed, "feed");

            try
            {
                var url = request.ToString();
                var operation = new RequestOperation(HttpMethod.Post, feed);
                return ExecuteFeedRequest(url, operation, out eTag);
            }
            catch (SDataClientException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
        /// <summary>
        /// Removes a resource from the syndication data source.
        /// </summary>
        /// <param name="request">The request from the syndication data source for the resource to be removed.</param>
        /// <param name="entry">the resource that is being deleted</param>
        /// <returns><b>true</b> if the syndication resource was successfully deleted; otherwise, <b>false</b>.</returns>
        public virtual bool DeleteEntry(SDataBaseRequest request, AtomEntry entry)
        {
            Guard.ArgumentNotNull(request, "request");

            try
            {
                var url = request.ToString();
                var eTag = entry != null ? entry.GetSDataHttpETag() : null;
                var batchItem = new SDataBatchRequestItem
                                {
                                    Url = url,
                                    Method = HttpMethod.Delete,
                                    ETag = eTag
                                };

                if (BatchProcess.Instance.AddToBatch(batchItem))
                {
                    return true;
                }

                var operation = new RequestOperation(HttpMethod.Delete) {ETag = eTag};
                var response = ExecuteRequest(url, operation, MediaType.AtomEntry, MediaType.Xml);
                return response.StatusCode == HttpStatusCode.OK;
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
Exemple #21
0
 /// <summary>
 /// Updates information about a syndication resource in the data source.
 /// </summary>
 /// <param name="request">The url from the syndication data source for the resource to be updated.</param>
 /// <param name="entry">
 ///     An object that implements the <see cref="ISyndicationResource"/> interface that represents the updated information for the resource.
 /// </param>
 public virtual AtomEntry UpdateEntry(SDataBaseRequest request, AtomEntry entry)
 {
     Guard.ArgumentNotNull(request, "request");
     return(UpdateEntry(request.ToString(), entry));
 }
Exemple #22
0
 /// <summary>
 /// Reads resource information from the data source based on the URL.
 /// </summary>
 /// <param name="request">Request for the syndication resource to get information for.</param>
 /// <returns>An <see cref="AtomEntry"/> populated with the specified resources' information from the data source.</returns>
 public virtual AtomEntry ReadEntry(SDataBaseRequest request)
 {
     return(ReadEntry(request, null));
 }
Exemple #23
0
        /// <summary>
        /// Adds a new syndication resource to the data source.
        /// </summary>
        /// <param name="request">The request that identifies the resource within the syndication data source.</param>
        /// <param name="feed"></param>
        public virtual AtomFeed CreateFeed(SDataBaseRequest request, AtomFeed feed)
        {
            string eTag;

            return(CreateFeed(request, feed, out eTag));
        }
        /// <summary>
        /// Reads resource information from the data source based on the URL and the specified ETag.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="eTag"></param>
        /// <returns></returns>
        public virtual AtomFeed ReadFeed(SDataBaseRequest request, ref string eTag)
        {
            Guard.ArgumentNotNull(request, "request");

            try
            {
                var requestUrl = request.ToString();
                var operation = new RequestOperation(HttpMethod.Get) {ETag = eTag};
                var response = ExecuteRequest(requestUrl, operation, MediaType.Atom, MediaType.Xml);
                eTag = response.ETag;
                return (AtomFeed) response.Content;
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
        /// <summary>
        /// Asynchronous PUT to the server
        /// </summary>
        /// <param name="request">The request that identifies the resource within the syndication data source.</param>
        /// <param name="resource">The resource that should be created asynchronously.</param>
        public virtual AsyncRequest CreateAsync(SDataBaseRequest request, ISyndicationResource resource)
        {
            Guard.ArgumentNotNull(request, "request");
            Guard.ArgumentNotNull(resource, "resource");

            try
            {
                var requestUrl = new SDataUri(request.ToString()) {TrackingId = Guid.NewGuid().ToString()}.ToString();
                var operation = new RequestOperation(HttpMethod.Post, resource);
                var response = ExecuteRequest(requestUrl, operation, MediaType.Xml);
                var tracking = (Tracking) response.Content;
                return new AsyncRequest(this, response.Location, tracking);
            }
            catch (Exception ex)
            {
                throw new SDataClientException(ex.Message, ex);
            }
        }
 /// <summary>
 /// Updates information about a syndication resource in the data source.
 /// </summary>
 /// <param name="request">The url from the syndication data source for the resource to be updated.</param>
 /// <param name="entry">
 ///     An object that implements the <see cref="ISyndicationResource"/> interface that represents the updated information for the resource.
 /// </param>
 public virtual AtomEntry UpdateEntry(SDataBaseRequest request, AtomEntry entry)
 {
     Guard.ArgumentNotNull(request, "request");
     return UpdateEntry(request.ToString(), entry);
 }
Exemple #27
0
 /// <summary>
 /// Removes a resource from the syndication data source.
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public virtual bool DeleteEntry(SDataBaseRequest request)
 {
     return(DeleteEntry(request, null));
 }