Removed unwanted packages and dlls
[pithos-ms-client] / trunk / Pithos.Core / IStatusKeeper.cs
1 #region\r
2 /* -----------------------------------------------------------------------\r
3  * <copyright file="IStatusKeeper.cs" company="GRNet">\r
4  * \r
5  * Copyright 2011-2012 GRNET S.A. All rights reserved.\r
6  *\r
7  * Redistribution and use in source and binary forms, with or\r
8  * without modification, are permitted provided that the following\r
9  * conditions are met:\r
10  *\r
11  *   1. Redistributions of source code must retain the above\r
12  *      copyright notice, this list of conditions and the following\r
13  *      disclaimer.\r
14  *\r
15  *   2. Redistributions in binary form must reproduce the above\r
16  *      copyright notice, this list of conditions and the following\r
17  *      disclaimer in the documentation and/or other materials\r
18  *      provided with the distribution.\r
19  *\r
20  *\r
21  * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS\r
22  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
23  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
24  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR\r
25  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\r
28  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\r
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
32  * POSSIBILITY OF SUCH DAMAGE.\r
33  *\r
34  * The views and conclusions contained in the software and\r
35  * documentation are those of the authors and should not be\r
36  * interpreted as representing official policies, either expressed\r
37  * or implied, of GRNET S.A.\r
38  * </copyright>\r
39  * -----------------------------------------------------------------------\r
40  */\r
41 #endregion\r
42 using System;\r
43 using System.Collections.Generic;\r
44 using System.Diagnostics.Contracts;\r
45 using System.IO;\r
46 using System.Linq;\r
47 using System.Threading;\r
48 using System.Threading.Tasks;\r
49 using NHibernate;\r
50 using Pithos.Interfaces;\r
51 using Pithos.Network;\r
52 \r
53 namespace Pithos.Core\r
54 {\r
55     [ContractClass(typeof(IStatusKeeperContract))]\r
56     public interface IStatusKeeper\r
57     {\r
58         void SetFileOverlayStatus(string path, FileOverlayStatus status);\r
59         void UpdateFileChecksum(string path, string etag, TreeHash treeHash);\r
60         void UpdateFileHashes(string path, TreeHash treeHash);\r
61         void SetFileStatus(string path, FileStatus status);\r
62         FileStatus GetFileStatus(string path);\r
63         void ClearFileStatus(string path);\r
64         FileOverlayStatus GetFileOverlayStatus(string path);\r
65         void ProcessExistingFiles(IEnumerable<FileInfo> paths);\r
66         void Stop();\r
67         void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus, string localFileMissingFromServer);\r
68         //Only update locations, not hashes\r
69         void StoreInfo(string path, ObjectInfo objectInfo);\r
70         void StoreInfo(string path, ObjectInfo objectInfo,TreeHash hash);\r
71         //T GetStatus<T>(string path,Func<FileState,T> getter,T defaultValue );\r
72         //void SetStatus(string path, Action<FileState> setter);        \r
73 \r
74         void StartProcessing(CancellationToken token);\r
75 \r
76         string BlockHash { get; set; }\r
77         int BlockSize { get; set; }\r
78         IStatusNotification StatusNotification { get; set; }\r
79         //ISessionFactory Factory { get; }\r
80         //IQueryable<T> Query<T>();\r
81 \r
82         void ChangeRoots(string oldPath, string newPath);\r
83         FileState GetStateByFilePath(string path);\r
84         void ClearFolderStatus(string path);\r
85         IEnumerable<FileState> GetChildren(FileState fileState);\r
86         void EnsureFileState(string path);\r
87 \r
88         void CleanupStaleStates(Network.AccountInfo accountInfo, List<ObjectInfo> objectInfos);\r
89         void CleanupOrphanStates();\r
90         //void UpdateLastMD5(FileInfo path, string etag);\r
91         void SaveCopy<T>(T state) where T:class;\r
92 \r
93         /// <summary>\r
94         /// Mark Unversioned all FileState rows from the database whose path\r
95         /// starts with one of the removed paths\r
96         /// </summary>\r
97         /// <param name="removed"></param>\r
98         void UnversionPaths(List<string> removed);\r
99 \r
100         List<FileState> GetAllStates();\r
101         List<string> GetAllStatePaths();\r
102         List<FileState> GetConflictStates();\r
103     }\r
104 \r
105     [ContractClassFor(typeof(IStatusKeeper))]\r
106     public abstract class IStatusKeeperContract : IStatusKeeper\r
107     {\r
108         public void SetFileOverlayStatus(string path, FileOverlayStatus status)\r
109         {\r
110             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
111             Contract.Requires(Path.IsPathRooted(path));\r
112             \r
113         }\r
114 \r
115         public void UpdateFileChecksum(string path, string etag, TreeHash treeHash)\r
116         {\r
117             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
118             Contract.Requires(treeHash!=null);\r
119             Contract.Requires(Path.IsPathRooted(path));\r
120         }\r
121 \r
122         public void UpdateFileHashes(string path, TreeHash treeHash)\r
123         {\r
124             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
125             Contract.Requires(treeHash!=null);\r
126             Contract.Requires(Path.IsPathRooted(path));\r
127         }\r
128 \r
129      /*   public void RemoveFileOverlayStatus(string path)\r
130         {\r
131             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
132             Contract.Requires(Path.IsPathRooted(path));\r
133         }*/\r
134 \r
135         public void RenameFileOverlayStatus(string oldPath, string newPath)\r
136         {\r
137             Contract.Requires(!String.IsNullOrWhiteSpace(oldPath));\r
138             Contract.Requires(Path.IsPathRooted(oldPath));\r
139             Contract.Requires(!String.IsNullOrWhiteSpace(newPath));\r
140             Contract.Requires(Path.IsPathRooted(newPath));\r
141 \r
142         }\r
143 \r
144         public void SetFileStatus(string path, FileStatus status)\r
145         {\r
146             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
147             Contract.Requires(Path.IsPathRooted(path));\r
148         }\r
149 \r
150         public FileStatus GetFileStatus(string path)\r
151         {\r
152             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
153             Contract.Requires(Path.IsPathRooted(path));\r
154 \r
155             return default(FileStatus);\r
156         }\r
157 \r
158         public FileOverlayStatus GetFileOverlayStatus(string path)\r
159         {\r
160             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
161             Contract.Requires(Path.IsPathRooted(path));\r
162 \r
163             return default(FileOverlayStatus);\r
164         }\r
165 \r
166         public void ProcessExistingFiles(IEnumerable<FileInfo> paths)\r
167         {\r
168             Contract.Requires(paths!=null);\r
169         }\r
170 \r
171         public void Stop()\r
172         {\r
173             \r
174         }\r
175 \r
176         public void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus, string localFileMissingFromServer)\r
177         {\r
178             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
179             Contract.Requires(Path.IsPathRooted(path));\r
180         }\r
181 \r
182         public void StoreInfo(string path, ObjectInfo objectInfo,TreeHash hash)\r
183         {\r
184             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
185             Contract.Requires(objectInfo!=null);\r
186             Contract.Requires(hash != null);\r
187             Contract.Requires(Path.IsPathRooted(path));\r
188         }\r
189 \r
190         public void StoreInfo(string path, ObjectInfo objectInfo)\r
191         {\r
192             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
193             Contract.Requires(objectInfo!=null);            \r
194             Contract.Requires(Path.IsPathRooted(path));\r
195         }\r
196 \r
197         public T GetStatus<T>(string path, Func<FileState, T> getter, T defaultValue)\r
198         {\r
199             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
200             Contract.Requires(getter!=null);\r
201             Contract.Requires(Path.IsPathRooted(path));\r
202 \r
203             return default(T);\r
204         }\r
205 \r
206         public void SetStatus(string path, Action<FileState> setter)\r
207         {\r
208             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
209             Contract.Requires(setter != null);\r
210             Contract.Requires(Path.IsPathRooted(path));\r
211         }\r
212 \r
213         public void SetNetworkState(string path, NetworkOperation operation)\r
214         {\r
215             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
216             Contract.Requires(Path.IsPathRooted(path));\r
217             Contract.Requires(Path.IsPathRooted(path));\r
218         }\r
219 \r
220         public NetworkOperation GetNetworkState(string path)\r
221         {\r
222             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
223             Contract.Requires(Path.IsPathRooted(path));\r
224 \r
225             return default(NetworkOperation);\r
226         }\r
227 \r
228         public void ClearFileStatus(string path)\r
229         {\r
230             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
231             Contract.Requires(Path.IsPathRooted(path));\r
232         }\r
233 \r
234         public void SetPithosStatus(PithosStatus status)\r
235         {\r
236         }\r
237 \r
238         public void StartProcessing(CancellationToken token)\r
239         {\r
240             Contract.Requires(token != null, "token can't be empty");\r
241         }\r
242 \r
243         public abstract string BlockHash { get; set; }\r
244         public abstract int BlockSize { get; set; }\r
245 \r
246         public IStatusNotification StatusNotification { get; set; }\r
247 \r
248         public ISessionFactory Factory { get; private set; }\r
249 \r
250         public IQueryable<T> Query<T>()\r
251         {\r
252             throw new NotImplementedException();\r
253         }\r
254 \r
255         public void ChangeRoots(string oldPath, string newPath)\r
256         {\r
257             Contract.Requires(!String.IsNullOrWhiteSpace(oldPath));\r
258             Contract.Requires(Path.IsPathRooted(oldPath));\r
259             Contract.Requires(!string.IsNullOrWhiteSpace(newPath));\r
260             Contract.Requires(Path.IsPathRooted(newPath));            \r
261         }\r
262 \r
263         public FileState GetStateByFilePath(string path)\r
264         {\r
265             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
266             Contract.Requires(Path.IsPathRooted(path));\r
267 \r
268             return null;\r
269         }\r
270 \r
271         public void ClearFolderStatus(string path)\r
272         {\r
273             Contract.Requires(!String.IsNullOrWhiteSpace(path));\r
274             Contract.Requires(Path.IsPathRooted(path));\r
275         }\r
276 \r
277         public IEnumerable<FileState> GetChildren(FileState fileState)\r
278         {\r
279             Contract.Requires(fileState!=null);\r
280             Contract.Ensures(Contract.Result<IEnumerable<FileState>>()!=null);\r
281             return default(IEnumerable<FileState>);\r
282         }\r
283 \r
284         public void EnsureFileState(string path)\r
285         {\r
286             \r
287         }\r
288 \r
289 \r
290         public void CleanupStaleStates(Network.AccountInfo accountInfo, List<ObjectInfo> objectInfos)\r
291         {\r
292             Contract.Requires(accountInfo != null);\r
293             Contract.Requires(objectInfos != null);\r
294         }\r
295 \r
296 \r
297         public void CleanupOrphanStates()\r
298         {            \r
299         }\r
300 \r
301         public void SaveCopy<T>(T state) where T:class\r
302         {\r
303             Contract.Requires(state != null);\r
304         }\r
305 \r
306         public void UnversionPaths(List<string> removed)\r
307         {\r
308             Contract.Requires(removed!=null);\r
309         }\r
310 \r
311         public List<FileState> GetAllStates()\r
312         {\r
313             return null;\r
314         }\r
315 \r
316         public List<string> GetAllStatePaths()\r
317         {\r
318             return null;\r
319         }\r
320 \r
321         public List<FileState> GetConflictStates()\r
322         {\r
323             return null;\r
324         }\r
325 \r
326         //public void UpdateLastMD5(FileInfo path, string etag)\r
327         //{            \r
328         //}\r
329     }\r
330 }\r