Permalink
Browse files

Added 'delta' feature support [SPRNETSOCIALDB-7]

  • Loading branch information...
bbaia committed Nov 3, 2012
1 parent c4dfa56 commit 53044f12bfaa711d253fad315c88466af0034abc
@@ -66,7 +66,11 @@ IDropbox dropboxApi = serviceProvider.GetApi(accessToken.Value, accessToken.Secr
Entry Move(string fromPath, string toPath);
+ FileRef CreateFileRef(string path);
+
Entry Copy(string fromPath, string toPath);
+
+ Entry CopyFileRef(string fromFileRef, string toPath);
Entry UploadFile(IResource file, string path);
@@ -76,6 +80,8 @@ IDropbox dropboxApi = serviceProvider.GetApi(accessToken.Value, accessToken.Secr
DropboxFile DownloadFile(string path, string revision);
+ DeltaPage Delta(string cursor);
+
Entry GetMetadata(string path);
Entry GetMetadata(string path, MetadataParameters parameters);
@@ -13,7 +13,7 @@
<!-- auto-generated -->
<copyright>Copyright 2012 SpringSource</copyright>
<!-- auto-generated -->
- <pubdate>Last Updated 2/7/2012</pubdate>
+ <pubdate>Last Updated 11/3/2012</pubdate>
<authorgroup>
<author>
<firstname>Bruno</firstname>
@@ -55,6 +55,7 @@ static void Main(string[] args)
// Use step by step debugging, or not
/*
+ DeltaPage deltaPage = dropbox.DeltaAsync(null).Result;
Entry createFolderEntry = dropbox.CreateFolderAsync("Spring Social").Result;
Entry uploadFileEntry = dropbox.UploadFileAsync(
new AssemblyResource("assembly://Spring.ConsoleQuickStart/Spring.ConsoleQuickStart/File.txt"),
@@ -138,6 +139,7 @@ static void Main(string[] args)
// Use step by step debugging, or not
/*
+ DeltaPage deltaPage = dropbox.Delta(null);
Entry createFolderEntry = dropbox.CreateFolder("Spring Social");
Entry uploadFileEntry = dropbox.UploadFile(
new AssemblyResource("assembly://Spring.ConsoleQuickStart/Spring.ConsoleQuickStart/File.txt"),
@@ -0,0 +1,77 @@
+#region License
+
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#endregion
+
+using System;
+
+namespace Spring.Social.Dropbox.Api
+{
+ /// <summary>
+ /// Represents a single entry in a <see cref="DeltaPage">delta page</see>.
+ /// </summary>
+ /// <author>Bruno Baia</author>
+#if !SILVERLIGHT
+ [Serializable]
+#endif
+ public class DeltaEntry
+ {
+ /// <summary>
+ /// Gets or sets the lower-cased path of the entry.
+ /// <para/>
+ /// Value is lower-cased because Dropbox treats file names in a case-insensitive but case-preserving way.
+ /// The Metadata property has the original case-preserved path.
+ /// </summary>
+ public string Path { get; set; }
+
+ /// <summary>
+ /// Gets or sets the <see cref="Entry">metadata information</see> for the entry to update your local state.
+ /// <para/>
+ /// If <see langword="null"/>, it means that this path should not exist on your Dropbox's copy of the file system.
+ /// Otherwise, it means that Dropbox has a file/folder at this path with the given metadata.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If <see langword="null"/>, indicates that there is no file/folder at the given path.
+ /// To update your local state to match, anything at path and all its children should be deleted.
+ /// Deleting a folder in your Dropbox will sometimes send down a single deleted entry for that folder,
+ /// and sometimes separate entries for the folder and all child paths.
+ /// If your local state doesn't have anything at path, ignore this entry.
+ /// </para>
+ /// <para>
+ /// If not <see langword="null"/>, indicates that there is a file/folder at the given path.
+ /// You should add the entry to your local path. To correctly process delta entries:
+ /// <list type="bullet">
+ /// <item>
+ /// If the new entry includes parent folders that don't yet exist in your local state,
+ /// create those parent folders in your local state.
+ /// </item>
+ /// <item>
+ /// If the new entry is a file, replace whatever your local state has at path with the new entry.
+ /// </item>
+ /// <item>
+ /// If the new entry is a folder, check what your local state has at path.
+ /// If it's a file, replace it with the new entry.
+ /// If it's a folder, apply the new entry to the folder, but do not modify the folder's children.
+ /// </item>
+ /// </list>
+ /// </para>
+ /// </remarks>
+ public Entry Metadata { get; set; }
+ }
+}
@@ -0,0 +1,68 @@
+#region License
+
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#endregion
+
+using System;
+using System.Collections.Generic;
+
+namespace Spring.Social.Dropbox.Api
+{
+ /// <summary>
+ /// Represents a page of delta entries returned by <code>Delta(string cursor)</code> method.
+ /// </summary>
+ /// <author>Bruno Baia</author>
+#if !SILVERLIGHT
+ [Serializable]
+#endif
+ public class DeltaPage
+ {
+ /// <summary>
+ /// Gets or sets a value that encodes the latest information that has been returned.
+ /// It is used to keep track of your current state.
+ /// <para/>
+ /// On the next call to <code>Delta(string cursor)</code> method, pass in this value
+ /// to return delta entries that have been recorded since this cursor was returned.
+ /// </summary>
+ public string Cursor { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether or not more entries are available.
+ /// <para/>
+ /// If <see langword="true"/> you can call <code>Delta(string cursor)</code> method again immediately to retrieve those entries.
+ /// If <see langword="false"/>, then wait for at least five minutes (preferably longer) before checking again.
+ /// </summary>
+ public bool HasMore { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether or not to clear your local state before processing the delta entries.
+ /// <para/>
+ /// Always <see langword="true"/> on the initial call to <code>Delta(string cursor)</code> method (i.e. when no cursor is passed in).
+ /// Otherwise, it is <see langword="true"/> in rare situations, such as after server or account maintenance,
+ /// or if a user deletes their app folder.
+ /// </summary>
+ public bool Reset { get; set; }
+
+ /// <summary>
+ /// Gets or sets the list of <see cref="DeltaEntry">delta entries</see>.
+ /// <para/>
+ /// Apply these entries to your local state to catch up with the Dropbox server's state.
+ /// </summary>
+ public IList<DeltaEntry> Entries { get; set; }
+ }
+}
@@ -212,6 +212,28 @@ public interface IDropbox : IApiBinding
/// <exception cref="DropboxApiException">If there is an error while communicating with Dropbox.</exception>
Task<DropboxFile> DownloadFileAsync(string path, string revision, CancellationToken cancellationToken);
+ /// <summary>
+ /// Asynchronously keeps up with changes to files and folders in a user's Dropbox.
+ /// <para/>
+ /// You can periodically call this method to get a list of metadatas,
+ /// which are instructions on how to update your local state to match the server's state.
+ /// </summary>
+ /// <param name="cursor">
+ /// A value that is used to keep track of your current state.
+ /// <para/>
+ /// On the first call, you should pass in <see langword="null"/>.
+ /// On subsequent calls, pass in the cursor value returned by the previous call.
+ /// </param>
+ /// <returns>
+ /// A <code>Task</code> that represents the asynchronous operation that can return
+ /// a single <see cref="DeltaPage">delta page</see> of results.
+ /// <para/>
+ /// The <see cref="DeltaPage"/>'s HasMore property will tell you whether the server has more pages of results to return.
+ /// If the server doesn't have more results, wait for at least five minutes (preferably longer) and poll again.
+ /// </returns>
+ /// <exception cref="DropboxApiException">If there is an error while communicating with Dropbox.</exception>
+ Task<DeltaPage> DeltaAsync(string cursor);
+
/// <summary>
/// Asynchronously retrieves file or folder metadata.
/// </summary>
@@ -479,6 +501,27 @@ public interface IDropbox : IApiBinding
/// <exception cref="DropboxApiException">If there is an error while communicating with Dropbox.</exception>
DropboxFile DownloadFile(string path, string revision);
+ /// <summary>
+ /// Keeps up with changes to files and folders in a user's Dropbox.
+ /// <para/>
+ /// You can periodically call this method to get a list of metadatas,
+ /// which are instructions on how to update your local state to match the server's state.
+ /// </summary>
+ /// <param name="cursor">
+ /// A value that is used to keep track of your current state.
+ /// <para/>
+ /// On the first call, you should pass in <see langword="null"/>.
+ /// On subsequent calls, pass in the cursor value returned by the previous call.
+ /// </param>
+ /// <returns>
+ /// A single <see cref="DeltaPage">delta page</see> of results.
+ /// <para/>
+ /// The <see cref="DeltaPage"/>'s HasMore property will tell you whether the server has more pages of results to return.
+ /// If the server doesn't have more results, wait for at least five minutes (preferably longer) and poll again.
+ /// </returns>
+ /// <exception cref="DropboxApiException">If there is an error while communicating with Dropbox.</exception>
+ DeltaPage Delta(string cursor);
+
/// <summary>
/// Retrieves file or folder metadata.
/// </summary>
@@ -786,6 +829,31 @@ public interface IDropbox : IApiBinding
/// <exception cref="DropboxApiException">If there is an error while communicating with Dropbox.</exception>
RestOperationCanceler DownloadFileAsync(string path, string revision, Action<RestOperationCompletedEventArgs<DropboxFile>> operationCompleted);
+ /// <summary>
+ /// Asynchronously keeps up with changes to files and folders in a user's Dropbox.
+ /// <para/>
+ /// You can periodically call this method to get a list of metadatas,
+ /// which are instructions on how to update your local state to match the server's state.
+ /// </summary>
+ /// <param name="cursor">
+ /// A value that is used to keep track of your current state.
+ /// <para/>
+ /// On the first call, you should pass in <see langword="null"/>.
+ /// On subsequent calls, pass in the cursor value returned by the previous call.
+ /// </param>
+ /// <param name="operationCompleted">
+ /// The <code>Action&lt;&gt;</code> to perform when the asynchronous request completes.
+ /// Provides a single <see cref="DeltaPage">delta page</see> of results.
+ /// <para/>
+ /// The <see cref="DeltaPage"/>'s HasMore property will tell you whether the server has more pages of results to return.
+ /// If the server doesn't have more results, wait for at least five minutes (preferably longer) and poll again.
+ /// </param>
+ /// <returns>
+ /// A <see cref="RestOperationCanceler"/> instance that allows to cancel the asynchronous operation.
+ /// </returns>
+ /// <exception cref="DropboxApiException">If there is an error while communicating with Dropbox.</exception>
+ RestOperationCanceler DeltaAsync(string cursor, Action<RestOperationCompletedEventArgs<DeltaPage>> operationCompleted);
+
/// <summary>
/// Asynchronously retrieves file or folder metadata.
/// </summary>
Oops, something went wrong.

0 comments on commit 53044f1

Please sign in to comment.