Notification changes
[pithos-ms-client] / trunk / Pithos.Core / IStatusKeeper.cs
index f004cf2..fb4cdab 100644 (file)
@@ -1,9 +1,51 @@
+#region
+/* -----------------------------------------------------------------------
+ * <copyright file="IStatusKeeper.cs" company="GRNet">
+ * 
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *   1. Redistributions of source code must retain the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer.
+ *
+ *   2. Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials
+ *      provided with the distribution.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and
+ * documentation are those of the authors and should not be
+ * interpreted as representing official policies, either expressed
+ * or implied, of GRNET S.A.
+ * </copyright>
+ * -----------------------------------------------------------------------
+ */
+#endregion
 using System;
 using System.Collections.Generic;
 using System.Diagnostics.Contracts;
 using System.IO;
 using System.Linq;
 using System.Threading;
+using System.Threading.Tasks;
 using Pithos.Interfaces;
 
 namespace Pithos.Core
@@ -11,61 +53,72 @@ namespace Pithos.Core
     [ContractClass(typeof(IStatusKeeperContract))]
     public interface IStatusKeeper
     {
-        void SetFileOverlayStatus(string path,FileOverlayStatus status);
-        void UpdateFileChecksum(string path, string checksum);
-        void RemoveFileOverlayStatus(string path);
+        Task SetFileOverlayStatus(string path, FileOverlayStatus status, string shortHash = null);
+        void UpdateFileChecksum(string path, string shortHash, string checksum);
         void SetFileStatus(string path, FileStatus status);
         FileStatus GetFileStatus(string path);
         void ClearFileStatus(string path);
-        void SetPithosStatus(PithosStatus status);
         FileOverlayStatus GetFileOverlayStatus(string path);
-        IEnumerable<string> StoreUnversionedFiles(ParallelQuery<string> paths);
+        void ProcessExistingFiles(IEnumerable<FileInfo> paths);
         void Stop();
         void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus);
         void StoreInfo(string path, ObjectInfo objectInfo);
-        T GetStatus<T>(string path,Func<FileState,T> getter,T defaultValue );
-        void SetStatus(string path, Action<FileState> setter);        
+        //T GetStatus<T>(string path,Func<FileState,T> getter,T defaultValue );
+        //void SetStatus(string path, Action<FileState> setter);        
 
         void StartProcessing(CancellationToken token);
 
         string BlockHash { get; set; }
         int BlockSize { get; set; }
+        void ChangeRoots(string oldPath, string newPath);
+        FileState GetStateByFilePath(string path);
+        void ClearFolderStatus(string path);
+        IEnumerable<FileState> GetChildren(FileState fileState);
+        void EnsureFileState(string path);
     }
 
     [ContractClassFor(typeof(IStatusKeeper))]
     public abstract class IStatusKeeperContract : IStatusKeeper
     {
-        public void SetFileOverlayStatus(string path, FileOverlayStatus status)
+        public Task SetFileOverlayStatus(string path, FileOverlayStatus status, string shortHash = null)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
+            Contract.Requires(Path.IsPathRooted(path));
+            return default(Task);
         }
 
-        public void UpdateFileChecksum(string path, string checksum)
+        public void UpdateFileChecksum(string path, string shortHash, string checksum)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
             Contract.Requires(checksum!=null);
+            Contract.Requires(Path.IsPathRooted(path));
         }
 
-        public void RemoveFileOverlayStatus(string path)
+     /*   public void RemoveFileOverlayStatus(string path)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
-        }
+            Contract.Requires(Path.IsPathRooted(path));
+        }*/
 
         public void RenameFileOverlayStatus(string oldPath, string newPath)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(oldPath));
+            Contract.Requires(Path.IsPathRooted(oldPath));
             Contract.Requires(!String.IsNullOrWhiteSpace(newPath));
+            Contract.Requires(Path.IsPathRooted(newPath));
 
         }
 
         public void SetFileStatus(string path, FileStatus status)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
+            Contract.Requires(Path.IsPathRooted(path));
         }
 
         public FileStatus GetFileStatus(string path)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
+            Contract.Requires(Path.IsPathRooted(path));
 
             return default(FileStatus);
         }
@@ -73,15 +126,14 @@ namespace Pithos.Core
         public FileOverlayStatus GetFileOverlayStatus(string path)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
+            Contract.Requires(Path.IsPathRooted(path));
 
             return default(FileOverlayStatus);
         }
 
-        public IEnumerable<string> StoreUnversionedFiles(ParallelQuery<string> paths)
+        public void ProcessExistingFiles(IEnumerable<FileInfo> paths)
         {
             Contract.Requires(paths!=null);
-
-            return default(IEnumerable<string>);
         }
 
         public void Stop()
@@ -92,18 +144,21 @@ namespace Pithos.Core
         public void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
+            Contract.Requires(Path.IsPathRooted(path));
         }
 
         public void StoreInfo(string path, ObjectInfo objectInfo)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
-            Contract.Requires(objectInfo!=null);            
+            Contract.Requires(objectInfo!=null);
+            Contract.Requires(Path.IsPathRooted(path));
         }
 
         public T GetStatus<T>(string path, Func<FileState, T> getter, T defaultValue)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
             Contract.Requires(getter!=null);
+            Contract.Requires(Path.IsPathRooted(path));
 
             return default(T);
         }
@@ -112,17 +167,20 @@ namespace Pithos.Core
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
             Contract.Requires(setter != null);
+            Contract.Requires(Path.IsPathRooted(path));
         }
 
         public void SetNetworkState(string path, NetworkOperation operation)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
-            Contract.Requires(Path.IsPathRooted(path));            
+            Contract.Requires(Path.IsPathRooted(path));
+            Contract.Requires(Path.IsPathRooted(path));
         }
 
         public NetworkOperation GetNetworkState(string path)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
+            Contract.Requires(Path.IsPathRooted(path));
 
             return default(NetworkOperation);
         }
@@ -130,6 +188,7 @@ namespace Pithos.Core
         public void ClearFileStatus(string path)
         {
             Contract.Requires(!String.IsNullOrWhiteSpace(path));
+            Contract.Requires(Path.IsPathRooted(path));
         }
 
         public void SetPithosStatus(PithosStatus status)
@@ -143,5 +202,38 @@ namespace Pithos.Core
 
         public abstract string BlockHash { get; set; }
         public abstract int BlockSize { get; set; }
+        public void ChangeRoots(string oldPath, string newPath)
+        {
+            Contract.Requires(!String.IsNullOrWhiteSpace(oldPath));
+            Contract.Requires(Path.IsPathRooted(oldPath));
+            Contract.Requires(!string.IsNullOrWhiteSpace(newPath));
+            Contract.Requires(Path.IsPathRooted(newPath));            
+        }
+
+        public FileState GetStateByFilePath(string path)
+        {
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));
+            Contract.Requires(Path.IsPathRooted(path));
+
+            return null;
+        }
+
+        public void ClearFolderStatus(string path)
+        {
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));
+            Contract.Requires(Path.IsPathRooted(path));
+        }
+
+        public IEnumerable<FileState> GetChildren(FileState fileState)
+        {
+            Contract.Requires(fileState!=null);
+            Contract.Ensures(Contract.Result<IEnumerable<FileState>>()!=null);
+            return default(IEnumerable<FileState>);
+        }
+
+        public void EnsureFileState(string path)
+        {
+            
+        }
     }
 }