Fixed release confgurations
[pithos-ms-client] / trunk / Pithos.Core / IStatusKeeper.cs
index 56f3bba..f1997ac 100644 (file)
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.Contracts;
-using System.IO;
-using System.Linq;
-using System.Threading;
-using Pithos.Interfaces;
-
-namespace Pithos.Core
-{
-    [ContractClass(typeof(IStatusKeeperContract))]
-    public interface IStatusKeeper
-    {
-        void SetFileOverlayStatus(string path,FileOverlayStatus status);
-        void UpdateFileChecksum(string path, string checksum);
-        void SetFileStatus(string path, FileStatus status);
-        FileStatus GetFileStatus(string path);
-        void ClearFileStatus(string path);
-        void SetPithosStatus(PithosStatus status);
-        FileOverlayStatus GetFileOverlayStatus(string path);
-        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);        
-
-        void StartProcessing(CancellationToken token);
-
-        string BlockHash { get; set; }
-        int BlockSize { get; set; }
-        void ChangeRoots(string oldPath, string newPath);
-    }
-
-    [ContractClassFor(typeof(IStatusKeeper))]
-    public abstract class IStatusKeeperContract : IStatusKeeper
-    {
-        public void SetFileOverlayStatus(string path, FileOverlayStatus status)
-        {
-            Contract.Requires(!String.IsNullOrWhiteSpace(path));
-            Contract.Requires(Path.IsPathRooted(path));
-        }
-
-        public void UpdateFileChecksum(string path, string checksum)
-        {
-            Contract.Requires(!String.IsNullOrWhiteSpace(path));
-            Contract.Requires(checksum!=null);
-            Contract.Requires(Path.IsPathRooted(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);
-        }
-
-        public FileOverlayStatus GetFileOverlayStatus(string path)
-        {
-            Contract.Requires(!String.IsNullOrWhiteSpace(path));
-            Contract.Requires(Path.IsPathRooted(path));
-
-            return default(FileOverlayStatus);
-        }
-
-        public void ProcessExistingFiles(IEnumerable<FileInfo> paths)
-        {
-            Contract.Requires(paths!=null);
-        }
-
-        public void Stop()
-        {
-            
-        }
-
-        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(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);
-        }
-
-        public void SetStatus(string path, Action<FileState> setter)
-        {
-            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));
-        }
-
-        public NetworkOperation GetNetworkState(string path)
-        {
-            Contract.Requires(!String.IsNullOrWhiteSpace(path));
-            Contract.Requires(Path.IsPathRooted(path));
-
-            return default(NetworkOperation);
-        }
-
-        public void ClearFileStatus(string path)
-        {
-            Contract.Requires(!String.IsNullOrWhiteSpace(path));
-            Contract.Requires(Path.IsPathRooted(path));
-        }
-
-        public void SetPithosStatus(PithosStatus status)
-        {
-        }
-
-        public void StartProcessing(CancellationToken token)
-        {
-            Contract.Requires(token != null, "token can't be empty");
-        }
-
-        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));            
-        }
-    }
-}
+#region\r
+/* -----------------------------------------------------------------------\r
+ * <copyright file="IStatusKeeper.cs" company="GRNet">\r
+ * \r
+ * Copyright 2011-2012 GRNET S.A. All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or\r
+ * without modification, are permitted provided that the following\r
+ * conditions are met:\r
+ *\r
+ *   1. Redistributions of source code must retain the above\r
+ *      copyright notice, this list of conditions and the following\r
+ *      disclaimer.\r
+ *\r
+ *   2. Redistributions in binary form must reproduce the above\r
+ *      copyright notice, this list of conditions and the following\r
+ *      disclaimer in the documentation and/or other materials\r
+ *      provided with the distribution.\r
+ *\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS\r
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR\r
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\r
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ * The views and conclusions contained in the software and\r
+ * documentation are those of the authors and should not be\r
+ * interpreted as representing official policies, either expressed\r
+ * or implied, of GRNET S.A.\r
+ * </copyright>\r
+ * -----------------------------------------------------------------------\r
+ */\r
+#endregion\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Diagnostics.Contracts;\r
+using System.IO;\r
+using System.Linq;\r
+using System.Threading;\r
+using System.Threading.Tasks;\r
+using NHibernate;\r
+using Pithos.Interfaces;\r
+using Pithos.Network;\r
+\r
+namespace Pithos.Core\r
+{\r
+    [ContractClass(typeof(IStatusKeeperContract))]\r
+    public interface IStatusKeeper\r
+    {\r
+        void SetFileOverlayStatus(string path, FileOverlayStatus status);\r
+        void UpdateFileChecksum(string path, string etag, TreeHash treeHash);\r
+        void UpdateFileHashes(string path, TreeHash treeHash);\r
+        void SetFileStatus(string path, FileStatus status);\r
+        FileStatus GetFileStatus(string path);\r
+        void ClearFileStatus(string path);\r
+        FileOverlayStatus GetFileOverlayStatus(string path);\r
+        void ProcessExistingFiles(IEnumerable<FileInfo> paths);\r
+        void Stop();\r
+        void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus, string localFileMissingFromServer);\r
+        //Only update locations, not hashes\r
+        void StoreInfo(string path, ObjectInfo objectInfo);\r
+        void StoreInfo(string path, ObjectInfo objectInfo,TreeHash hash);\r
+        //T GetStatus<T>(string path,Func<FileState,T> getter,T defaultValue );\r
+        //void SetStatus(string path, Action<FileState> setter);        \r
+\r
+        void StartProcessing(CancellationToken token);\r
+\r
+        string BlockHash { get; set; }\r
+        int BlockSize { get; set; }\r
+        IStatusNotification StatusNotification { get; set; }\r
+        //ISessionFactory Factory { get; }\r
+        //IQueryable<T> Query<T>();\r
+\r
+        void ChangeRoots(string oldPath, string newPath);\r
+        FileState GetStateByFilePath(string path);\r
+        void ClearFolderStatus(string path);\r
+        IEnumerable<FileState> GetChildren(FileState fileState);\r
+        void EnsureFileState(string path);\r
+\r
+        void CleanupStaleStates(Network.AccountInfo accountInfo, List<ObjectInfo> objectInfos);\r
+        void CleanupOrphanStates();\r
+        //void UpdateLastMD5(FileInfo path, string etag);\r
+        void SaveCopy<T>(T state) where T:class;\r
+\r
+        /// <summary>\r
+        /// Mark Unversioned all FileState rows from the database whose path\r
+        /// starts with one of the removed paths\r
+        /// </summary>\r
+        /// <param name="removed"></param>\r
+        void UnversionPaths(List<string> removed);\r
+\r
+        List<FileState> GetAllStates();\r
+        List<string> GetAllStatePaths();\r
+        List<FileState> GetConflictStates();\r
+    }\r
+\r
+    [ContractClassFor(typeof(IStatusKeeper))]\r
+    public abstract class IStatusKeeperContract : IStatusKeeper\r
+    {\r
+        public void SetFileOverlayStatus(string path, FileOverlayStatus status)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+            \r
+        }\r
+\r
+        public void UpdateFileChecksum(string path, string etag, TreeHash treeHash)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(treeHash!=null);\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+        }\r
+\r
+        public void UpdateFileHashes(string path, TreeHash treeHash)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(treeHash!=null);\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+        }\r
+\r
+     /*   public void RemoveFileOverlayStatus(string path)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+        }*/\r
+\r
+        public void RenameFileOverlayStatus(string oldPath, string newPath)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(oldPath));\r
+            Contract.Requires(Path.IsPathRooted(oldPath));\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(newPath));\r
+            Contract.Requires(Path.IsPathRooted(newPath));\r
+\r
+        }\r
+\r
+        public void SetFileStatus(string path, FileStatus status)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+        }\r
+\r
+        public FileStatus GetFileStatus(string path)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+\r
+            return default(FileStatus);\r
+        }\r
+\r
+        public FileOverlayStatus GetFileOverlayStatus(string path)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+\r
+            return default(FileOverlayStatus);\r
+        }\r
+\r
+        public void ProcessExistingFiles(IEnumerable<FileInfo> paths)\r
+        {\r
+            Contract.Requires(paths!=null);\r
+        }\r
+\r
+        public void Stop()\r
+        {\r
+            \r
+        }\r
+\r
+        public void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus, string localFileMissingFromServer)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+        }\r
+\r
+        public void StoreInfo(string path, ObjectInfo objectInfo,TreeHash hash)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(objectInfo!=null);\r
+            Contract.Requires(hash != null);\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+        }\r
+\r
+        public void StoreInfo(string path, ObjectInfo objectInfo)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(objectInfo!=null);            \r
+            Contract.Requires(Path.IsPathRooted(path));\r
+        }\r
+\r
+        public T GetStatus<T>(string path, Func<FileState, T> getter, T defaultValue)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(getter!=null);\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+\r
+            return default(T);\r
+        }\r
+\r
+        public void SetStatus(string path, Action<FileState> setter)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(setter != null);\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+        }\r
+\r
+        public void SetNetworkState(string path, NetworkOperation operation)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+        }\r
+\r
+        public NetworkOperation GetNetworkState(string path)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+\r
+            return default(NetworkOperation);\r
+        }\r
+\r
+        public void ClearFileStatus(string path)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+        }\r
+\r
+        public void SetPithosStatus(PithosStatus status)\r
+        {\r
+        }\r
+\r
+        public void StartProcessing(CancellationToken token)\r
+        {\r
+            Contract.Requires(token != null, "token can't be empty");\r
+        }\r
+\r
+        public abstract string BlockHash { get; set; }\r
+        public abstract int BlockSize { get; set; }\r
+\r
+        public IStatusNotification StatusNotification { get; set; }\r
+\r
+        public ISessionFactory Factory { get; private set; }\r
+\r
+        public IQueryable<T> Query<T>()\r
+        {\r
+            throw new NotImplementedException();\r
+        }\r
+\r
+        public void ChangeRoots(string oldPath, string newPath)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(oldPath));\r
+            Contract.Requires(Path.IsPathRooted(oldPath));\r
+            Contract.Requires(!string.IsNullOrWhiteSpace(newPath));\r
+            Contract.Requires(Path.IsPathRooted(newPath));            \r
+        }\r
+\r
+        public FileState GetStateByFilePath(string path)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+\r
+            return null;\r
+        }\r
+\r
+        public void ClearFolderStatus(string path)\r
+        {\r
+            Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
+            Contract.Requires(Path.IsPathRooted(path));\r
+        }\r
+\r
+        public IEnumerable<FileState> GetChildren(FileState fileState)\r
+        {\r
+            Contract.Requires(fileState!=null);\r
+            Contract.Ensures(Contract.Result<IEnumerable<FileState>>()!=null);\r
+            return default(IEnumerable<FileState>);\r
+        }\r
+\r
+        public void EnsureFileState(string path)\r
+        {\r
+            \r
+        }\r
+\r
+\r
+        public void CleanupStaleStates(Network.AccountInfo accountInfo, List<ObjectInfo> objectInfos)\r
+        {\r
+            Contract.Requires(accountInfo != null);\r
+            Contract.Requires(objectInfos != null);\r
+        }\r
+\r
+\r
+        public void CleanupOrphanStates()\r
+        {            \r
+        }\r
+\r
+        public void SaveCopy<T>(T state) where T:class\r
+        {\r
+            Contract.Requires(state != null);\r
+        }\r
+\r
+        public void UnversionPaths(List<string> removed)\r
+        {\r
+            Contract.Requires(removed!=null);\r
+        }\r
+\r
+        public List<FileState> GetAllStates()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        public List<string> GetAllStatePaths()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        public List<FileState> GetConflictStates()\r
+        {\r
+            return null;\r
+        }\r
+\r
+        //public void UpdateLastMD5(FileInfo path, string etag)\r
+        //{            \r
+        //}\r
+    }\r
+}\r