Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into stable

Conflicts:
	Raven.Tests.Silverlight/Generate.cs
	Raven.Tests/Querying/UsingDynamicQueryWithRemoteServer.cs
	Raven.Tests/Suggestions/Person.cs
	Raven.Tests/Suggestions/SuggestionsHelper.cs
  • Loading branch information...
commit 76f3b74e3b3a662cee9aa2f0941cab40c330b97e 2 parents ab7aca1 + a66615d
@ayende ayende authored
Showing with 10,270 additions and 5,714 deletions.
  1. +104 −0 Bundles/Raven.Bundles.Tests/Authorization/Bugs/Matthew.cs
  2. +1 −0  Bundles/Raven.Bundles.Tests/Raven.Bundles.Tests.csproj
  3. +1 −0  Bundles/Raven.Bundles.Tests/Replication/ReplicationDestinationDisabled.cs
  4. +1 −0  Bundles/Raven.Bundles.Tests/Replication/ReplicationWithOAuth.cs
  5. +1 −1  DefaultConfigs/RavenDb.exe.config
  6. +1 −1  DefaultConfigs/Web.config
  7. +13 −17 Raven.Abstractions/Connection/HttpRavenRequest.cs
  8. +29 −33 Raven.Abstractions/Connection/HttpRavenRequestFactory.cs
  9. +1 −1  {Raven.Client.Lightweight → Raven.Abstractions}/Connection/WebRequestEventArgs.cs
  10. +1 −1  Raven.Abstractions/Data/Constants.cs
  11. +1 −1  Raven.Abstractions/Data/Facet.cs
  12. +118 −0 Raven.Abstractions/Data/HighlightedField.cs
  13. +39 −39 Raven.Abstractions/Data/IJsonDocumentMetadata.cs
  14. +32 −7 Raven.Abstractions/Data/IndexQuery.cs
  15. +2 −2 Raven.Abstractions/Data/JsonDocument.cs
  16. +4 −1 Raven.Abstractions/Data/PeriodicBackupSetup.cs
  17. +26 −26 Raven.Abstractions/Data/PutResult.cs
  18. +22 −13 Raven.Abstractions/Data/QueryResult.cs
  19. +3 −0  Raven.Abstractions/Data/SpatialIndexQuery.cs
  20. +37 −29 Raven.Abstractions/Data/StringDistanceTypes.cs
  21. +6 −0 Raven.Abstractions/Data/SuggestionQuery.cs
  22. +68 −68 Raven.Abstractions/Exceptions/ConcurrencyException.cs
  23. +48 −0 Raven.Abstractions/Extensions/TaskExtensions.cs
  24. +30 −0 Raven.Abstractions/Indexing/FieldTermVector.cs
  25. +38 −7 Raven.Abstractions/Indexing/IndexDefinition.cs
  26. +19 −0 Raven.Abstractions/Indexing/SuggestionOptions.cs
  27. +51 −36 Raven.Abstractions/Json/Linq/DictionaryWithParentSnapshot.cs
  28. +14 −3 Raven.Abstractions/Json/Linq/RavenJArray.cs
  29. +3 −2 Raven.Abstractions/Json/Linq/RavenJObject.cs
  30. +3 −1 Raven.Abstractions/Json/Linq/RavenJToken.cs
  31. +13 −1 Raven.Abstractions/Json/Linq/RavenJTokenEqualityComparer.cs
  32. +4 −0 Raven.Abstractions/Json/Linq/RavenJTokenReader.cs
  33. +6 −1 Raven.Abstractions/Json/Linq/RavenJValue.cs
  34. +30 −14 Raven.Abstractions/Linq/DynamicJsonObject.cs
  35. +3 −0  Raven.Abstractions/Logging/LogManager.cs
  36. +2 −2 {Raven.Client.Lightweight/Document → Raven.Abstractions}/OAuth/AbstractAuthenticator.cs
  37. +49 −12 {Raven.Client.Lightweight/Document → Raven.Abstractions}/OAuth/SecuredAuthenticator.cs
  38. +7 −0 Raven.Abstractions/Raven.Abstractions.csproj
  39. +3 −2 Raven.Abstractions/Smuggler/SmugglerApiBase.cs
  40. +2 −0  Raven.Abstractions/Util/CompletedTask.cs
  41. +8 −1 Raven.Abstractions/Util/IncludesUtil.cs
  42. +4 −4 Raven.Client.Embedded/Changes/EmbeddableDatabaseChanges.cs
  43. +2 −2 Raven.Client.Embedded/Changes/EmbeddableObservableWithTask.cs
  44. +1 −1  Raven.Client.Embedded/Changes/FilteringObservableWithTask.cs
  45. +107 −15 Raven.Client.Embedded/EmbeddedAsyncServerClient.cs
  46. +9 −9 Raven.Client.Embedded/EmbeddedDatabaseCommands.cs
  47. +1 −1  Raven.Client.Lightweight/Bundles/MoreLikeThis/MoreLikeThisExtensions.cs
  48. +1 −1  Raven.Client.Lightweight/Changes/IDatabaseChanges.cs
  49. +20 −28 Raven.Client.Lightweight/Changes/LocalConnectionState.cs
  50. +50 −76 Raven.Client.Lightweight/Changes/RemoteDatabaseChanges.cs
  51. +2 −2 Raven.Client.Lightweight/Changes/TaskObservable.cs
  52. +7 −2 Raven.Client.Lightweight/Changes/TaskedObservable.cs
  53. +81 −34 Raven.Client.Lightweight/Connection/Async/AsyncServerClient.cs
  54. +15 −3 Raven.Client.Lightweight/Connection/Async/IAsyncDatabaseCommands.cs
  55. +7 −0 Raven.Client.Lightweight/Connection/HttpJsonRequest.cs
  56. +2 −1  Raven.Client.Lightweight/Connection/HttpJsonRequestFactory.cs
  57. +8 −3 Raven.Client.Lightweight/Connection/IDatabaseCommands.cs
  58. +6 −0 Raven.Client.Lightweight/Connection/IRavenQueryInspector.cs
  59. +23 −2 Raven.Client.Lightweight/Connection/Profiling/ConcurrentBoundedList.cs
  60. +1 −0  Raven.Client.Lightweight/Connection/Profiling/ProfilingContext.cs
  61. +13 −0 Raven.Client.Lightweight/Connection/Profiling/RequestResultArgs.cs
  62. +3 −1 Raven.Client.Lightweight/Connection/RavenTransactionAccessor.cs
  63. +19 −29 Raven.Client.Lightweight/Connection/SerializationHelper.cs
  64. +63 −53 Raven.Client.Lightweight/Connection/ServerClient.cs
  65. +158 −37 Raven.Client.Lightweight/Document/AbstractDocumentQuery.cs
  66. +17 −12 Raven.Client.Lightweight/Document/Async/AsyncDocumentSession.cs
  67. +55 −4 Raven.Client.Lightweight/Document/AsyncDocumentQuery.cs
  68. +8 −3 Raven.Client.Lightweight/Document/AsyncShardedDocumentQuery.cs
  69. +11 −6 Raven.Client.Lightweight/Document/Batches/LazyFacetsOperation.cs
  70. +1 −1  Raven.Client.Lightweight/Document/Batches/LazyLoadOperation.cs
  71. +1 −1  Raven.Client.Lightweight/Document/BulkInsertOperation.cs
  72. +16 −2 Raven.Client.Lightweight/Document/DTC/PendingTransactionRecovery.cs
  73. +57 −0 Raven.Client.Lightweight/Document/DocumentConvention.cs
  74. +65 −7 Raven.Client.Lightweight/Document/DocumentQuery.cs
  75. +12 −11 Raven.Client.Lightweight/Document/DocumentSession.cs
  76. +40 −17 Raven.Client.Lightweight/Document/DocumentStore.cs
  77. +10 −2 Raven.Client.Lightweight/Document/EntityToJson.cs
  78. +40 −0 Raven.Client.Lightweight/Document/IAbstractDocumentQuery.cs
  79. +70 −15 Raven.Client.Lightweight/Document/InMemoryDocumentSessionOperations.cs
  80. +2 −0  Raven.Client.Lightweight/Document/OAuth/BasicAuthenticator.cs
  81. +14 −14 Raven.Client.Lightweight/Document/RavenClientEnlistment.cs
  82. +35 −17 Raven.Client.Lightweight/Document/RemoteBulkInsertOperation.cs
  83. +1 −0  Raven.Client.Lightweight/Document/SessionOperations/QueryOperation.cs
  84. +11 −6 Raven.Client.Lightweight/Document/ShardedDocumentQuery.cs
  85. +49 −0 Raven.Client.Lightweight/Extensions/AsyncDocumentSessionExtesions.cs
  86. +37 −25 Raven.Client.Lightweight/Extensions/MultiTenancyExtensions.cs
  87. +2 −38 Raven.Client.Lightweight/Extensions/TaskExtensions.cs
  88. +54 −0 Raven.Client.Lightweight/FieldHighlightings.cs
  89. +5 −0 Raven.Client.Lightweight/IAdvancedDocumentSessionOperations.cs
  90. +26 −1 Raven.Client.Lightweight/IAsyncAdvancedSessionOperations.cs
  91. +6 −0 Raven.Client.Lightweight/IAsyncDocumentQuery.cs
  92. +6 −5 Raven.Client.Lightweight/IAsyncDocumentSession.cs
  93. +5 −0 Raven.Client.Lightweight/IDocumentQuery.cs
  94. +73 −0 Raven.Client.Lightweight/IDocumentQueryBase.cs
  95. +40 −0 Raven.Client.Lightweight/IDocumentQueryCustomization.cs
  96. +2 −1  Raven.Client.Lightweight/IDocumentSession.cs
  97. +2 −1  Raven.Client.Lightweight/ISyncAdvancedSessionOperation.cs
  98. +60 −36 Raven.Client.Lightweight/Indexes/AbstractGenericIndexCreationTask.cs
  99. +14 −5 Raven.Client.Lightweight/Indexes/AbstractIndexCreationTask.cs
  100. +2 −1  Raven.Client.Lightweight/Indexes/AbstractMultiMapIndexCreationTask.cs
  101. +58 −6 Raven.Client.Lightweight/Indexes/ExpressionStringBuilder.cs
  102. +40 −2 Raven.Client.Lightweight/Indexes/IndexDefinitionBuilder.cs
  103. +9 −0 Raven.Client.Lightweight/Indexes/RavenDocumentsByEntityName.cs
  104. +2 −2 Raven.Client.Lightweight/Linq/IDocumentQueryGenerator.cs
  105. +23 −0 Raven.Client.Lightweight/Linq/LinqPathProvider.cs
  106. +26 −19 Raven.Client.Lightweight/Linq/RavenQueryInspector.cs
  107. +24 −15 Raven.Client.Lightweight/Linq/RavenQueryProvider.cs
  108. +106 −26 Raven.Client.Lightweight/Linq/RavenQueryProviderProcessor.cs
  109. +90 −25 Raven.Client.Lightweight/PublicExtensions/LinqExtensions.cs
  110. +6 −4 Raven.Client.Lightweight/Raven.Client.Lightweight.csproj
  111. +29 −0 Raven.Client.Lightweight/RavenQueryHighlightings.cs
  112. +5 −4 Raven.Client.Lightweight/Shard/AsyncShardedDocumentSession.cs
  113. +12 −11 Raven.Client.Lightweight/Shard/BaseShardedDocumentSession.cs
  114. +4 −2 Raven.Client.Lightweight/Shard/ShardedDatabaseChanges.cs
  115. +5 −5 Raven.Client.Lightweight/Shard/ShardedDocumentSession.cs
  116. +3 −2 Raven.Client.Lightweight/Shard/ShardedObservableWithTask.cs
  117. +22 −0 Raven.Client.Lightweight/Util/CSharpClassName.cs
  118. +90 −1 Raven.Client.Lightweight/Util/SimpleCache.cs
  119. +2 −16 Raven.Client.MvcIntegration/js/config.js
  120. +8 −1 Raven.Client.MvcIntegration/js/models/ProfilerData.js
  121. +1,527 −1,425 Raven.Client.MvcIntegration/js/vendor/backbone.js
  122. +1,228 −1,071 Raven.Client.MvcIntegration/js/vendor/underscore.js
  123. +8 −0 Raven.Client.Silverlight/Connection/HttpJsonRequest.cs
  124. +1 −0  Raven.Client.Silverlight/Connection/HttpJsonRequestFactory.cs
  125. +34 −0 Raven.Client.Silverlight/Imports/Connection/WebRequestEventArgs.cs
  126. +94 −0 Raven.Client.Silverlight/Imports/Document/OAuth/BasicAuthenticator.cs
  127. +43 −12 Raven.Client.Silverlight/Raven.Client.Silverlight.csproj
  128. +0 −21 Raven.Client.VisualBasic.Tests/Data_NewIndex.vb
  129. +0 −119 Raven.Client.VisualBasic.Tests/LinqQueriesUsingVB.vb
  130. +0 −13 Raven.Client.VisualBasic.Tests/My Project/Application.Designer.vb
  131. +0 −10 Raven.Client.VisualBasic.Tests/My Project/Application.myapp
  132. +0 −35 Raven.Client.VisualBasic.Tests/My Project/AssemblyInfo.vb
  133. +0 −62 Raven.Client.VisualBasic.Tests/My Project/Resources.Designer.vb
  134. +0 −117 Raven.Client.VisualBasic.Tests/My Project/Resources.resx
  135. +0 −73 Raven.Client.VisualBasic.Tests/My Project/Settings.Designer.vb
  136. +0 −7 Raven.Client.VisualBasic.Tests/My Project/Settings.settings
  137. +0 −13 Raven.Client.VisualBasic.Tests/PortalModule.vb
  138. +0 −24 Raven.Client.VisualBasic.Tests/PortalPageSettings.vb
  139. +0 −13 Raven.Client.VisualBasic.Tests/PortalZone.vb
  140. +0 −152 Raven.Client.VisualBasic.Tests/Raven.Client.VisualBasic.Tests.vbproj
  141. +0 −5 Raven.Client.VisualBasic.Tests/TestClass.vb
  142. +0 −4 Raven.Client.VisualBasic.Tests/packages.config
  143. +170 −138 Raven.Database/Bundles/PeriodicBackups/PeriodicBackupTask.cs
  144. +2 −3 Raven.Database/Bundles/Replication/Responders/Behaviors/AttachmentReplicationBehavior.cs
  145. +3 −5 Raven.Database/Bundles/Replication/Responders/Behaviors/DocumentReplicationBehavior.cs
  146. +4 −12 Raven.Database/Bundles/Replication/Responders/Behaviors/SingleItemReplicationBehavior.cs
  147. +25 −3 Raven.Database/Bundles/Replication/Tasks/ReplicationStrategy.cs
  148. +1 −1  Raven.Database/Bundles/Replication/Triggers/AncestryPutTrigger.cs
  149. +1 −1  Raven.Database/Bundles/Replication/Triggers/AttachmentAncestryPutTrigger.cs
  150. +2 −2 Raven.Database/Bundles/Replication/Triggers/RemoveConflictOnAttachmentPutTrigger.cs
  151. +2 −2 Raven.Database/Bundles/Replication/Triggers/RemoveConflictOnPutTrigger.cs
  152. +1 −2  Raven.Database/Bundles/Replication/Triggers/VirtualAttachmentDeleteTrigger.cs
  153. +1 −2  Raven.Database/Bundles/Replication/Triggers/VirtualDeleteTrigger.cs
  154. +6 −3 Raven.Database/Bundles/SpellChecker/SpellChecker.cs
  155. +10 −0 Raven.Database/Bundles/SqlReplication/LastReplicatedEtag.cs
  156. +18 −0 Raven.Database/Bundles/SqlReplication/SqlReplicationConfig.cs
  157. +14 −0 Raven.Database/Bundles/SqlReplication/SqlReplicationStatus.cs
  158. +570 −0 Raven.Database/Bundles/SqlReplication/SqlReplicationTask.cs
  159. +1 −1  Raven.Database/Commercial/ValidateLicense.cs
  160. +1 −1  Raven.Database/Config/ConfigOptionDocs.cs
  161. +93 −129 Raven.Database/Config/InMemoryRavenConfiguration.cs
  162. +22 −0 Raven.Database/Config/Settings/BooleanSetting.cs
  163. +31 −0 Raven.Database/Config/Settings/IntegerSetting.cs
  164. +33 −0 Raven.Database/Config/Settings/IntegerSettingWithMin.cs
  165. +27 −0 Raven.Database/Config/Settings/MultipliedIntegerSetting.cs
  166. +30 −0 Raven.Database/Config/Settings/Setting.cs
  167. +40 −0 Raven.Database/Config/Settings/StringSetting.cs
  168. +48 −0 Raven.Database/Config/Settings/TimeSpanSetting.cs
  169. +191 −0 Raven.Database/Config/StronglyTypedRavenSettings.cs
  170. +36 −36 Raven.Database/Data/AttachmentInformation.cs
  171. +15 −0 Raven.Database/Data/DynamicQueryMapping.cs
  172. +56 −54 Raven.Database/Data/IndexQueryResult.cs
  173. +117 −35 Raven.Database/DocumentDatabase.cs
  174. +10 −2 Raven.Database/Extensions/AdminFinder.cs
  175. +25 −8 Raven.Database/Extensions/HttpContextExtensions.cs
  176. +31 −4 Raven.Database/Extensions/HttpExtensions.cs
  177. +34 −1 Raven.Database/Extensions/IndexingExtensions.cs
  178. +23 −6 Raven.Database/Impl/Clustering/ClusterInspecter.cs
  179. +4 −1 Raven.Database/Impl/DatabaseBulkOperations.cs
  180. +2 −2 Raven.Database/Impl/DocumentCacher.cs
  181. +2 −0  Raven.Database/Impl/DocumentRetriever.cs
  182. +10 −4 Raven.Database/Indexing/AbstractIndexingExecuter.cs
  183. +61 −43 Raven.Database/Indexing/AnonymousObjectToLuceneDocumentConverter.cs
  184. +13 −7 Raven.Database/Indexing/CurrentIndexingScope.cs
  185. +8 −0 Raven.Database/Indexing/DefaultBackgroundTaskExecuter.cs
  186. +2 −1  Raven.Database/Indexing/IIndexExtension.cs
  187. +98 −13 Raven.Database/Indexing/Index.cs
  188. +7 −1 Raven.Database/Indexing/IndexStorage.cs
  189. +2 −0  Raven.Database/Indexing/IndexToWorkOn.cs
  190. +143 −13 Raven.Database/Indexing/IndexingExecuter.cs
  191. +12 −4 Raven.Database/Indexing/MapReduceIndex.cs
  192. +16 −4 Raven.Database/Indexing/QueryBuilder.cs
  193. +78 −64 Raven.Database/Indexing/ReducingExecuter.cs
  194. +1 −1  Raven.Database/Indexing/SimpleIndex.cs
  195. +21 −30 Raven.Database/Indexing/Sorting/{SpatialDistanceSortField.cs → SpatialDistanceFieldComparatorSource.cs}
  196. +4 −1 Raven.Database/Indexing/SpatialIndex.cs
  197. +11 −1 Raven.Database/Json/JsonPatcher.cs
  198. +74 −23 Raven.Database/Json/ScriptedJsonPatcher.cs
  199. +5 −4 Raven.Database/Json/ScriptsCache.cs
  200. +17 −1 Raven.Database/Linq/AbstractViewGenerator.cs
  201. +3 −1 Raven.Database/Linq/QueryParsingUtils.cs
  202. +5 −0 Raven.Database/Plugins/Builtins/CreateSilverlightIndexes.cs
  203. +0 −19 Raven.Database/Plugins/Builtins/Tenants/ModifiedTenantDatabase.cs
  204. +5 −0 Raven.Database/Plugins/Catalogs/FilteredCatalog.cs
  205. +32 −8 Raven.Database/Queries/DynamicQueryOptimizer.cs
  206. +4 −1 Raven.Database/Queries/DynamicQueryRunner.cs
  207. +21 −13 Raven.Database/Queries/FacetedQueryRunner.cs
  208. +7 −2 Raven.Database/Queries/FacetedQueryRunnerExtensions.cs
  209. +28 −10 Raven.Database/Queries/SuggestionQueryIndexExtension.cs
  210. +17 −4 Raven.Database/Queries/SuggestionQueryRunner.cs
  211. +20 −1 Raven.Database/Raven.Database.csproj
  212. +18 −17 Raven.Database/Rhino.Licensing/AbstractLicenseValidator.cs
  213. +71 −129 Raven.Database/Rhino.Licensing/SntpClient.cs
  214. +15 −0 Raven.Database/Server/Abstractions/HttpListenerRequestAdapter.cs
  215. +11 −0 Raven.Database/Server/Abstractions/HttpListenerResponseAdapter.cs
  216. +15 −0 Raven.Database/Server/Abstractions/HttpRequestAdapter.cs
  217. +11 −0 Raven.Database/Server/Abstractions/HttpResponseAdapter.cs
  218. +2 −0  Raven.Database/Server/Abstractions/IHttpRequest.cs
  219. +1 −0  Raven.Database/Server/Abstractions/IHttpResponse.cs
  220. +0 −1  Raven.Database/Server/Abstractions/PrincipalWithDatabaseAccess.cs
  221. +2 −1  Raven.Database/Server/AnonymousUserAccessMode.cs
  222. +1 −1  Raven.Database/Server/Connections/EventsTransport.cs
  223. +10 −4 Raven.Database/Server/HttpServer.cs
  224. +1 −1  Raven.Database/Server/Responders/Admin/AdminResponder.cs
  225. +2 −2 Raven.Database/Server/Responders/Admin/AdminRestore.cs
  226. +5 −5 Raven.Database/Server/Responders/BulkInsert.cs
  227. +40 −0 Raven.Database/Server/Responders/DatabaseStorageSizes.cs
  228. +1 −1  Raven.Database/Server/Responders/Databases.cs
  229. +50 −0 Raven.Database/Server/Responders/Debugging/DebugDocReferences.cs
  230. +87 −0 Raven.Database/Server/Responders/Debugging/DebugUser.cs
  231. +11 −0 Raven.Database/Server/Responders/Docs.cs
  232. +14 −4 Raven.Database/Server/Responders/Document.cs
  233. +8 −6 Raven.Database/Server/Responders/Facets.cs
  234. +2 −2 Raven.Database/Server/Responders/Index.cs
  235. +15 −0 Raven.Database/Server/Responders/MultiGet.cs
  236. +10 −0 Raven.Database/Server/Responders/SuggestionResponder.cs
  237. +3 −1 Raven.Database/Server/Security/MixedModeRequestAuthorizer.cs
  238. +3 −0  Raven.Database/Server/Security/OAuth/AccessTokenBody.cs
  239. +45 −0 Raven.Database/Server/Security/OAuth/OAuthCookie.cs
  240. +20 −8 Raven.Database/Server/Security/OAuth/OAuthRequestAuthorizer.cs
  241. +6 −2 Raven.Database/Server/Security/Windows/WindowsAuthConfigureHttpListener.cs
  242. +20 −44 Raven.Database/Server/Security/Windows/WindowsRequestAuthorizer.cs
  243. +9 −62 Raven.Database/Storage/Esent/Backup/RestoreOperation.cs
  244. +17 −12 Raven.Database/Storage/Esent/StorageActions/DocumentStorageActions.cs
  245. +63 −29 Raven.Database/Storage/Esent/StorageActions/Documents.cs
  246. +28 −15 Raven.Database/Storage/Esent/StorageActions/EsentUtil.cs
  247. +17 −1 Raven.Database/Storage/Esent/StorageActions/Indexing.cs
  248. +11 −6 Raven.Database/Storage/Esent/StorageActions/Lists.cs
  249. +44 −15 Raven.Database/Storage/Esent/StorageActions/MappedResults.cs
  250. +16 −3 Raven.Database/Storage/Esent/StorageActions/OptimizedIndexReader.cs
  251. +2 −0  Raven.Database/Storage/Esent/StorageActions/Util.cs
  252. +4 −0 Raven.Database/Storage/Esent/StorageActionsAccessor.cs
  253. +48 −4 Raven.Database/Storage/Esent/TransactionalStorage.cs
  254. +10 −2 Raven.Database/Storage/Esent/TransactionalStorageConfigurator.cs
  255. +1 −0  Raven.Database/Storage/IIndexingStorageActions.cs
  256. +4 −3 Raven.Database/Storage/IMappedResultsStorageAction.cs
  257. +1 −0  Raven.Database/Storage/ITransactionalStorage.cs
  258. +2 −3 Raven.Database/Storage/IndexDefinitionStorage.cs
  259. +11 −1 Raven.Database/Storage/Managed/IndexingStorageActions.cs
  260. +38 −14 Raven.Database/Storage/Managed/MappedResultsStorageAction.cs
  261. +1 −1  Raven.Database/Storage/Managed/Munin/Table.cs
  262. +5 −0 Raven.Database/Storage/Managed/TransactionalStorage.cs
  263. +1 −1  Raven.Server/App.config
  264. +8 −0 Raven.Server/Program.cs
  265. +1 −1  Raven.Studio/Assets/Styles.xaml
  266. +14 −10 Raven.Studio/Assets/Types.xaml
  267. +1 −1  Raven.Studio/Commands/BackupCommand.cs
  268. +19 −11 Raven.Studio/Commands/CreateDatabaseCommand.cs
  269. +8 −5 Raven.Studio/Commands/CsvImportCommand.cs
  270. +1 −1  Raven.Studio/Commands/DeleteDatabaseCommand.cs
  271. +31 −6 Raven.Studio/Commands/RestoreCommand.cs
  272. +54 −5 Raven.Studio/Commands/SaveSettingsCommand.cs
  273. +24 −0 Raven.Studio/Controls/DateTimePicker.xaml
  274. +107 −0 Raven.Studio/Controls/DateTimePicker.xaml.cs
  275. +20 −6 Raven.Studio/Controls/NewDatabase.xaml
  276. +1 −1  Raven.Studio/Controls/NewDatabase.xaml.cs
  277. +1 −4 Raven.Studio/Features/Documents/ColumnModelBindingExtensions.cs
  278. +38 −1 Raven.Studio/Features/Indexes/EditIndexView.xaml
  279. +4 −4 Raven.Studio/Features/JsonEditor/JsonAstHelpers.cs
  280. +3 −0  Raven.Studio/Features/Logs/LogsModel.cs
  281. +210 −211 Raven.Studio/Features/Settings/AuthorizationSettingSectionView.xaml
  282. +33 −24 Raven.Studio/Features/Settings/PeriodicBackupSettingsSectionView.xaml
  283. +1 −1  Raven.Studio/Features/Settings/ReplicationsSettingsSectionView.xaml
  284. +4 −1 Raven.Studio/Features/Settings/SettingsView.xaml
  285. +225 −0 Raven.Studio/Features/Settings/SqlReplicationScriptIntelliPromptProvider.cs
  286. +148 −0 Raven.Studio/Features/Settings/SqlReplicationsSettingsSectionView.xaml
  287. +22 −0 Raven.Studio/Features/Settings/SqlReplicationsSettingsSectionView.xaml.cs
  288. +57 −0 Raven.Studio/Infrastructure/Converters/FromEnumWithDescription.cs
  289. +5 −2 Raven.Studio/Infrastructure/Converters/GetApiKeyDirectLink.cs
  290. +20 −0 Raven.Studio/Infrastructure/Converters/IntParamEqualityConverter.cs
  291. +4 −5 Raven.Studio/Infrastructure/Converters/{BooleanToIntConverter.cs → MillisecondsToMinutesConverter.cs}
  292. +20 −0 Raven.Studio/Infrastructure/Converters/VisibilityByParamInEqualityConverter.cs
  293. +1 −1  Raven.Studio/Infrastructure/Model.cs
  294. +9 −3 Raven.Studio/MainPage.xaml
  295. +3 −0  Raven.Studio/Models/AllDocumentsModel.cs
  296. +1 −0  Raven.Studio/Models/ApiKeysSectionModel.cs
  297. +98 −98 Raven.Studio/Models/AuthorizationSettingsSectionModel.cs
  298. +1 −1  Raven.Studio/Models/CollectionsModel.cs
  299. +1 −1  Raven.Studio/Models/DatabaseListItemModel.cs
  300. +17 −7 Raven.Studio/Models/DatabaseModel.cs
Sorry, we could not display the entire diff because too many files (429) changed.
View
104 Bundles/Raven.Bundles.Tests/Authorization/Bugs/Matthew.cs
@@ -0,0 +1,104 @@
+extern alias client;
+using Raven.Client.Exceptions;
+using client::Raven.Bundles.Authorization.Model;
+using System.Collections.Generic;
+using Raven.Client;
+using Xunit;
+
+namespace Raven.Bundles.Tests.Authorization.Bugs
+{
+ public class Matthew : AuthorizationTest
+ {
+ [Fact]
+ public void AuthorizationDemo_Works()
+ {
+ // Arrange
+ using (IDocumentSession session = store.OpenSession())
+ {
+ session.Store(
+ new AuthorizationRole
+ {
+ Id = "Authorization/Roles/Nurses",
+ Permissions =
+ {
+ new OperationPermission
+ {
+ Allow = true,
+ Operation = "Appointment/Schedule",
+ Tags = new List<string> {"Patient"}
+ }
+ }
+ });
+
+ // Allow doctors to authorize hospitalizations
+ session.Store(
+ new AuthorizationRole
+ {
+ Id = "Authorization/Roles/Doctors",
+ Permissions =
+ {
+ new OperationPermission
+ {
+ Allow = true,
+ Operation = "Hospitalization/Authorize",
+ Tags = new List<string> {"Patient"}
+ }
+ }
+ });
+ // Associate Patient with clinic
+ var maryMallon = new Patient {Id = "Patients/MaryMallon"};
+ session.Store(maryMallon);
+ client::Raven.Client.Authorization.AuthorizationClientExtensions.SetAuthorizationFor(session, maryMallon,
+ new DocumentAuthorization
+ {
+ Tags =
+ {
+ "Clinics/Kirya",
+ "Patient"
+ }
+ });
+
+ // Associate Doctor with clinic
+ session.Store(
+ new AuthorizationUser
+ {
+ Id = "Authorization/Users/DrHowser",
+ Name = "Doogie Howser",
+ Roles = {"Authorization/Roles/Doctors"},
+ Permissions =
+ {
+ new OperationPermission
+ {
+ Allow = true,
+ Operation = "Patient/View",
+ Tags = new List<string> {"Clinics/Kirya"}
+ },
+ }
+ });
+ session.SaveChanges();
+ }
+
+
+ // Assert
+ using (IDocumentSession session = store.OpenSession())
+ {
+ client::Raven.Client.Authorization.AuthorizationClientExtensions.SecureFor(session,
+ "Authorization/Users/NotDrHowser",
+ "Hospitalization/Authorize");
+ var readVetoException = Assert.Throws<ReadVetoException>(() => session.Load<Patient>("Patients/MaryMallon"));
+ Assert.Contains(
+ "Could not find user: Authorization/Users/NotDrHowser for secured document: Patients/MaryMallon",
+ readVetoException.Message);
+ }
+ }
+ }
+
+ public class Patient
+ {
+ public string Id { get; set; }
+
+ public void AuthorizeHospitalization()
+ {
+ }
+ }
+}
View
1  Bundles/Raven.Bundles.Tests/Raven.Bundles.Tests.csproj
@@ -71,6 +71,7 @@
<Compile Include="Authorization\Bugs\Jalchr.cs" />
<Compile Include="Authorization\Bugs\Kwal.cs" />
<Compile Include="Authorization\Bugs\LoadingSavedInfo.cs" />
+ <Compile Include="Authorization\Bugs\Matthew.cs" />
<Compile Include="Authorization\Bugs\WhenUsingMultiTenancy.cs" />
<Compile Include="Authorization\Bugs\WithChangingOfUser.cs" />
<Compile Include="Authorization\CanAskAuthQuestions.cs" />
View
1  Bundles/Raven.Bundles.Tests/Replication/ReplicationDestinationDisabled.cs
@@ -1,6 +1,7 @@
extern alias database;
using System.Threading;
using Raven.Abstractions.Data;
+using Raven.Client.Extensions;
using Raven.Tests.Bundles.Replication;
using Xunit;
View
1  Bundles/Raven.Bundles.Tests/Replication/ReplicationWithOAuth.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading;
using Raven.Abstractions.Data;
+using Raven.Client.Extensions;
using Raven.Json.Linq;
using Raven.Tests.Bundles.Replication;
using Xunit;
View
2  DefaultConfigs/RavenDb.exe.config
@@ -8,7 +8,7 @@
<runtime>
<loadFromRemoteSources enabled="true"/>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
- <probing privatePath="Analyzers"/>
+ <probing privatePath="Analyzers;Plugins"/>
</assemblyBinding>
</runtime>
</configuration>
View
2  DefaultConfigs/Web.config
@@ -36,7 +36,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
- <probing privatePath="Analyzers"/>
+ <probing privatePath="Analyzers;Plugins"/>
</assemblyBinding>
View
30 Raven.Abstractions/Connection/HttpRavenRequest.cs
@@ -45,18 +45,13 @@ public HttpRavenRequest(string url, string method, Action<RavenConnectionStringO
private HttpWebRequest CreateRequest()
{
- var request = (HttpWebRequest) System.Net.WebRequest.Create(url);
+ var request = (HttpWebRequest)System.Net.WebRequest.Create(url);
request.Method = method;
if (method == "POST" || method == "PUT")
request.Headers["Content-Encoding"] = "gzip";
request.Headers["Accept-Encoding"] = "deflate,gzip";
request.ContentType = "application/json; charset=utf-8";
- if (connectionStringOptions.Credentials != null)
- request.Credentials = connectionStringOptions.Credentials;
- else
- request.UseDefaultCredentials = true;
-
configureRequest(connectionStringOptions, request);
return request;
}
@@ -65,8 +60,8 @@ public void Write(Stream streamToWrite)
{
postedStream = streamToWrite;
using (var stream = WebRequest.GetRequestStream())
- using(var countingStream = new CountingStream(stream, l => NumberOfBytesWrittenCompressed = l))
- using(var commpressedStream = new GZipStream(countingStream, CompressionMode.Compress))
+ using (var countingStream = new CountingStream(stream, l => NumberOfBytesWrittenCompressed = l))
+ using (var commpressedStream = new GZipStream(countingStream, CompressionMode.Compress))
using (var countingStream2 = new CountingStream(commpressedStream, l => NumberOfBytesWrittenUncompressed = l))
{
streamToWrite.CopyTo(countingStream2);
@@ -128,13 +123,13 @@ public T ExecuteRequest<T>()
{
T result = default(T);
SendRequestToServer(response =>
- {
- using (var stream = response.GetResponseStreamWithHttpDecompression())
- using (var reader = new StreamReader(stream))
- {
- result = reader.JsonDeserialization<T>();
- }
- });
+ {
+ using (var stream = response.GetResponseStreamWithHttpDecompression())
+ using (var reader = new StreamReader(stream))
+ {
+ result = reader.JsonDeserialization<T>();
+ }
+ });
return result;
}
@@ -188,7 +183,8 @@ private void SendRequestToServer(Action<WebResponse> action)
if (response == null)
throw;
- if (response.StatusCode != HttpStatusCode.Unauthorized)
+ if (response.StatusCode != HttpStatusCode.Unauthorized &&
+ response.StatusCode != HttpStatusCode.PreconditionFailed)
{
using (var streamReader = new StreamReader(response.GetResponseStreamWithHttpDecompression()))
{
@@ -235,7 +231,7 @@ private void RecreateWebRequest()
if (postedStream != null)
{
postedStream.Position = 0;
- using (var stream = newWebRequest.GetRequestStream())
+ using (var stream = newWebRequest.GetRequestStream())
using (var compressedData = new GZipStream(stream, CompressionMode.Compress))
{
postedStream.CopyTo(compressedData);
View
62 Raven.Abstractions/Connection/HttpRavenRequestFactory.cs
@@ -1,6 +1,9 @@
+using System;
+using System.Collections.Concurrent;
using System.IO;
using System.Net;
using Raven.Abstractions.Data;
+using Raven.Abstractions.OAuth;
namespace Raven.Abstractions.Connection
{
@@ -8,51 +11,44 @@ public class HttpRavenRequestFactory
{
public int? RequestTimeoutInMs { get; set; }
- private bool RefreshOauthToken(RavenConnectionStringOptions options, WebResponse response)
+ readonly ConcurrentDictionary<string, SecuredAuthenticator> authenticators = new ConcurrentDictionary<string, SecuredAuthenticator>();
+
+ public void ConfigureRequest(RavenConnectionStringOptions options, WebRequest request)
{
- var oauthSource = response.Headers["OAuth-Source"];
- if (string.IsNullOrEmpty(oauthSource))
- return false;
+ if (RequestTimeoutInMs.HasValue)
+ request.Timeout = RequestTimeoutInMs.Value;
+
- var authRequest = PrepareOAuthRequest(options, oauthSource);
- using (var authResponse = authRequest.GetResponse())
- using (var stream = authResponse.GetResponseStreamWithHttpDecompression())
- using (var reader = new StreamReader(stream))
+ if (options.ApiKey == null)
{
- options.CurrentOAuthToken = "Bearer " + reader.ReadToEnd();
+ request.Credentials = options.Credentials ?? CredentialCache.DefaultNetworkCredentials;
+ return;
}
- return true;
- }
-
- private HttpWebRequest PrepareOAuthRequest(RavenConnectionStringOptions options, string oauthSource)
- {
- var authRequest = (HttpWebRequest) WebRequest.Create(oauthSource);
- authRequest.Credentials = options.Credentials;
- authRequest.Headers["Accept-Encoding"] = "deflate,gzip";
- authRequest.Accept = "application/json;charset=UTF-8";
- authRequest.Headers["grant_type"] = "client_credentials";
+ var value = authenticators.GetOrAdd(options.ApiKey, s => new SecuredAuthenticator(s));
- if (string.IsNullOrEmpty(options.ApiKey) == false)
- authRequest.Headers["Api-Key"] = options.ApiKey;
-
- return authRequest;
+ value.ConfigureRequest(this, new WebRequestEventArgs
+ {
+ Request = request
+ });
}
- public void ConfigureRequest(RavenConnectionStringOptions options, WebRequest request)
+ public HttpRavenRequest Create(string url, string method, RavenConnectionStringOptions connectionStringOptions)
{
- request.Credentials = options.Credentials ?? CredentialCache.DefaultNetworkCredentials;
-
- if (RequestTimeoutInMs.HasValue)
- request.Timeout = RequestTimeoutInMs.Value;
-
- if (string.IsNullOrEmpty(options.CurrentOAuthToken) == false)
- request.Headers["Authorization"] = options.CurrentOAuthToken;
+ return new HttpRavenRequest(url, method, ConfigureRequest, HandleUnauthorizedResponse, connectionStringOptions);
}
- public HttpRavenRequest Create(string url, string method, RavenConnectionStringOptions connectionStringOptions)
+ private bool HandleUnauthorizedResponse(RavenConnectionStringOptions options, WebResponse webResponse)
{
- return new HttpRavenRequest(url, method, ConfigureRequest, RefreshOauthToken, connectionStringOptions);
+ if (options.ApiKey == null)
+ return false;
+
+ var value = authenticators.GetOrAdd(options.ApiKey, s => new SecuredAuthenticator(s));
+
+ var oauthSource = options.Url + "/OAuth/API-Key";
+
+ var result = value.DoOAuthRequest(oauthSource);
+ return result != null;
}
}
}
View
2  ...ent.Lightweight/Connection/WebRequestEventArgs.cs → Raven.Abstractions/Connection/WebRequestEventArgs.cs
@@ -11,7 +11,7 @@
using Raven.Client.Silverlight.Connection;
#endif
-namespace Raven.Client.Connection
+namespace Raven.Abstractions.Connection
{
/// <summary>
/// Event arguments for the event of creating a <see cref="WebRequest"/>
View
2  Raven.Abstractions/Data/Constants.cs
@@ -12,7 +12,7 @@ static Constants()
{
{"Text", "The encryption is correct."}
};
- InDatabaseKeyVerificationDocumentContents.EnsureSnapshot();
+ InDatabaseKeyVerificationDocumentContents.EnsureCannotBeChangeAndEnableSnapshotting();
}
public const string RavenClientPrimaryServerUrl = "Raven-Client-Primary-Server-Url";
View
2  Raven.Abstractions/Data/Facet.cs
@@ -17,7 +17,7 @@ public class Facet
public List<string> Ranges { get; set; }
public int? MaxResults { get; set; }
public FacetTermSortMode TermSortMode { get; set; }
- public bool InclueRemainingTerms { get; set; }
+ public bool IncludeRemainingTerms { get; set; }
public Facet()
{
View
118 Raven.Abstractions/Data/HighlightedField.cs
@@ -0,0 +1,118 @@
+// -----------------------------------------------------------------------
+// <copyright file="HighlightedField.cs" company="Hibernating Rhinos LTD">
+// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
+// </copyright>
+// -----------------------------------------------------------------------
+
+using System.Globalization;
+using System.Text.RegularExpressions;
+
+namespace Raven.Abstractions.Data
+{
+ /// <summary>
+ /// Represent a field highlight options
+ /// </summary>
+ public sealed class HighlightedField
+ {
+ private static readonly Regex FieldOptionMatch =
+ new Regex(@"^(?<Field>\w+):(?<FragmentLength>\d+),(?<FragmentCount>\d+)(,(?<FragmentsField>\w+))?$",
+#if !SILVERLIGHT
+ RegexOptions.Compiled
+#else
+ RegexOptions.None
+#endif
+ );
+
+ public HighlightedField(string field, int fragmentLength, int fragmentCount, string fragmentsField)
+ {
+ Field = field;
+ FragmentLength = fragmentLength;
+ FragmentCount = fragmentCount;
+ FragmentsField = fragmentsField;
+ }
+
+ /// <summary>
+ /// Gets or sets the field.
+ /// </summary>
+ public string Field { get; private set; }
+
+ /// <summary>
+ /// Gets or sets the fragment length.
+ /// </summary>
+ public int FragmentLength { get; private set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating how many highlight fragments should be created for the field
+ /// </summary>
+ public int FragmentCount { get; private set; }
+
+ /// <summary>
+ /// Gets or sets the field in query result item for highlighting fragments
+ /// </summary>
+ public string FragmentsField { get; private set; }
+
+ /// <summary>
+ /// Converts the string representation of a field highlighting options to the <see cref="HighlightedField" /> class.
+ /// </summary>
+ /// <param name="value">
+ /// Field highlighting options
+ /// <example>Text:250,3,TextFragments</example>
+ /// </param>
+ /// <param name="result"></param>
+ /// <returns></returns>
+ public static bool TryParse(string value, out HighlightedField result)
+ {
+ result = null;
+
+ var match = FieldOptionMatch.Match(value);
+
+ if (!match.Success)
+ return false;
+
+ var field = match.Groups["Field"].Value;
+
+ if (string.IsNullOrWhiteSpace(field))
+ return false;
+
+ int fragmentLength;
+
+ if (!int.TryParse(
+ match.Groups["FragmentLength"].Value,
+ NumberStyles.None,
+ CultureInfo.InvariantCulture,
+ out fragmentLength))
+ return false;
+
+ int fragmentCount;
+
+ if (!int.TryParse(
+ match.Groups["FragmentCount"].Value,
+ NumberStyles.None,
+ CultureInfo.InvariantCulture,
+ out fragmentCount))
+ return false;
+
+ var fragmentsField = match.Groups["FragmentsField"].Value;
+
+ result = new HighlightedField(field, fragmentLength, fragmentCount, fragmentsField);
+
+ return true;
+ }
+
+ public override string ToString()
+ {
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0}:{1},{2}{3}",
+ this.Field,
+ this.FragmentLength,
+ this.FragmentCount,
+ string.IsNullOrEmpty(this.FragmentsField) ? null : ',' + this.FragmentsField);
+ }
+
+ public HighlightedField Clone()
+ {
+ return new HighlightedField(Field, FragmentLength, FragmentCount, FragmentsField);
+ }
+ }
+}
View
78 Raven.Abstractions/Data/IJsonDocumentMetadata.cs
@@ -1,40 +1,40 @@
-using System;
-using Raven.Json.Linq;
-
-namespace Raven.Abstractions.Data
-{
- /// <summary>
- /// Interface that is used purely internally
- /// </summary>
- public interface IJsonDocumentMetadata
- {
- /// <summary>
- /// Gets or sets the metadata for the document
- /// </summary>
- /// <value>The metadata.</value>
- RavenJObject Metadata { get; set; }
-
- /// <summary>
- /// Gets or sets the key for the document
- /// </summary>
- /// <value>The key.</value>
- string Key { get; set; }
-
- /// <summary>
- /// Gets or sets a value indicating whether this document is non authoritative (modified by uncommitted transaction).
- /// </summary>
- bool? NonAuthoritativeInformation { get; set; }
-
- /// <summary>
- /// Gets or sets the etag.
- /// </summary>
- /// <value>The etag.</value>
- Guid? Etag { get; set; }
-
- /// <summary>
- /// Gets or sets the last modified date for the document
- /// </summary>
- /// <value>The last modified.</value>
- DateTime? LastModified { get; set; }
- }
+using System;
+using Raven.Json.Linq;
+
+namespace Raven.Abstractions.Data
+{
+ /// <summary>
+ /// Interface that is used purely internally
+ /// </summary>
+ public interface IJsonDocumentMetadata
+ {
+ /// <summary>
+ /// Gets or sets the metadata for the document
+ /// </summary>
+ /// <value>The metadata.</value>
+ RavenJObject Metadata { get; set; }
+
+ /// <summary>
+ /// Gets or sets the key for the document
+ /// </summary>
+ /// <value>The key.</value>
+ string Key { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether this document is non authoritative (modified by uncommitted transaction).
+ /// </summary>
+ bool? NonAuthoritativeInformation { get; set; }
+
+ /// <summary>
+ /// Gets or sets the etag.
+ /// </summary>
+ /// <value>The etag.</value>
+ Guid? Etag { get; set; }
+
+ /// <summary>
+ /// Gets or sets the last modified date for the document
+ /// </summary>
+ /// <value>The last modified.</value>
+ DateTime? LastModified { get; set; }
+ }
}
View
39 Raven.Abstractions/Data/IndexQuery.cs
@@ -1,4 +1,4 @@
-//-----------------------------------------------------------------------
+//-----------------------------------------------------------------------
// <copyright file="IndexQuery.cs" company="Hibernating Rhinos LTD">
// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// </copyright>
@@ -126,7 +126,22 @@ public IndexQuery()
/// </summary>
public bool DebugOptionGetIndexEntries { get; set; }
- /// <summary>
+ /// <summary>
+ /// Gets or sets the options to highlight the fields
+ /// </summary>
+ public HighlightedField[] HighlightedFields { get; set; }
+
+ /// <summary>
+ /// Gets or sets the highlighter pre tags
+ /// </summary>
+ public string[] HighlighterPreTags { get; set; }
+
+ /// <summary>
+ /// Gets or sets the highlighter post tags
+ /// </summary>
+ public string[] HighlighterPostTags { get; set; }
+
+ /// <summary>
/// Gets the index query URL.
/// </summary>
/// <param name="operationUrl">The operation URL.</param>
@@ -172,10 +187,15 @@ public void AppendQueryString(StringBuilder path)
AppendMinimalQueryString(path);
- path
- .Append("&start=").Append(Start)
- .Append("&pageSize=").Append(PageSize)
- .Append("&aggregation=").Append(AggregationOperation);
+ if (Start != 0)
+ path.Append("&start=").Append(Start);
+
+ path.Append("&pageSize=").Append(PageSize);
+
+
+ if(AggregationOperation != AggregationOperation.None)
+ path.Append("&aggregation=").Append(AggregationOperation);
+
FieldsToFetch.ApplyIfNotNull(field => path.Append("&fetch=").Append(Uri.EscapeDataString(field)));
GroupBy.ApplyIfNotNull(field => path.Append("&groupBy=").Append(Uri.EscapeDataString(field)));
SortedFields.ApplyIfNotNull(
@@ -198,6 +218,11 @@ public void AppendQueryString(StringBuilder path)
{
path.Append("&cutOffEtag=").Append(CutoffEtag.Value.ToString());
}
+
+ this.HighlightedFields.ApplyIfNotNull(field => path.Append("&highlight=").Append(field));
+ this.HighlighterPreTags.ApplyIfNotNull(tag=>path.Append("&preTags=").Append(tag));
+ this.HighlighterPostTags.ApplyIfNotNull(tag=>path.Append("&postTags=").Append(tag));
+
if(DebugOptionGetIndexEntries)
@@ -236,7 +261,7 @@ public IndexQuery Clone()
}
}
- public enum QueryOperator
+ public enum QueryOperator
{
Or,
And
View
4 Raven.Abstractions/Data/JsonDocument.cs
@@ -92,8 +92,8 @@ public RavenJObject Metadata
/// <returns></returns>
public RavenJObject ToJson()
{
- DataAsJson.EnsureSnapshot();
- Metadata.EnsureSnapshot();
+ DataAsJson.EnsureCannotBeChangeAndEnableSnapshotting();
+ Metadata.EnsureCannotBeChangeAndEnableSnapshotting();
var doc = (RavenJObject)DataAsJson.CreateSnapshot();
var metadata = (RavenJObject)Metadata.CreateSnapshot();
View
5 Raven.Abstractions/Data/PeriodicBackupSetup.cs
@@ -15,7 +15,10 @@ public class PeriodicBackupSetup
public string GlacierVaultName { get; set; }
public string S3BucketName { get; set; }
public string AwsRegionEndpoint { get; set; }
- public int Interval { get; set; }
+
+ public string LocalFolderName { get; set; }
+
+ public int IntervalMilliseconds { get; set; }
public Guid LastDocsEtag { get; set; }
public Guid LastAttachmentsEtag { get; set; }
View
52 Raven.Abstractions/Data/PutResult.cs
@@ -1,26 +1,26 @@
-//-----------------------------------------------------------------------
-// <copyright file="PutResult.cs" company="Hibernating Rhinos LTD">
-// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-using System;
-
-namespace Raven.Abstractions.Data
-{
- /// <summary>
- /// The result of a PUT operation
- /// </summary>
- public class PutResult
- {
- /// <summary>
- /// Gets or sets the key.
- /// </summary>
- /// <value>The key.</value>
- public string Key { get; set; }
- /// <summary>
- /// Gets or sets the generated Etag for the PUT operation
- /// </summary>
- /// <value>The Etag.</value>
- public Guid ETag { get; set; }
- }
-}
+//-----------------------------------------------------------------------
+// <copyright file="PutResult.cs" company="Hibernating Rhinos LTD">
+// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+using System;
+
+namespace Raven.Abstractions.Data
+{
+ /// <summary>
+ /// The result of a PUT operation
+ /// </summary>
+ public class PutResult
+ {
+ /// <summary>
+ /// Gets or sets the key.
+ /// </summary>
+ /// <value>The key.</value>
+ public string Key { get; set; }
+ /// <summary>
+ /// Gets or sets the generated Etag for the PUT operation
+ /// </summary>
+ /// <value>The Etag.</value>
+ public Guid ETag { get; set; }
+ }
+}
View
35 Raven.Abstractions/Data/QueryResult.cs
@@ -67,6 +67,11 @@ public class QueryResult
/// </summary>
public Guid ResultEtag { get; set; }
+ /// <summary>
+ /// Gets or sets highlighter results
+ /// </summary>
+ public Dictionary<string, Dictionary<string, string[]>> Highlightings { get; set; }
+
/// <summary>
/// Gets or sets a value indicating whether any of the documents returned by this query
/// are non authoritative (modified by uncommitted transaction).
@@ -85,6 +90,7 @@ public QueryResult()
{
Results = new List<RavenJObject>();
Includes = new List<RavenJObject>();
+ Highlightings = new Dictionary<string, Dictionary<string, string[]>>();
}
/// <summary>
@@ -94,11 +100,11 @@ public void EnsureSnapshot()
{
foreach (var result in Results)
{
- result.EnsureSnapshot();
+ result.EnsureCannotBeChangeAndEnableSnapshotting();
}
foreach (var result in Includes)
{
- result.EnsureSnapshot();
+ result.EnsureCannotBeChangeAndEnableSnapshotting();
}
}
@@ -107,17 +113,20 @@ public void EnsureSnapshot()
/// </summary>
public QueryResult CreateSnapshot()
{
- return new QueryResult
- {
- Results = new List<RavenJObject>(Results.Select(x => (RavenJObject)x.CreateSnapshot())),
- Includes = new List<RavenJObject>(Includes.Select(x => (RavenJObject)x.CreateSnapshot())),
- IndexEtag = IndexEtag,
- IndexName = IndexName,
- IndexTimestamp = IndexTimestamp,
- IsStale = IsStale,
- SkippedResults = SkippedResults,
- TotalResults = TotalResults,
- };
+ return new QueryResult
+ {
+ Results = new List<RavenJObject>(this.Results.Select(x => (RavenJObject)x.CreateSnapshot())),
+ Includes = new List<RavenJObject>(this.Includes.Select(x => (RavenJObject)x.CreateSnapshot())),
+ IndexEtag = this.IndexEtag,
+ IndexName = this.IndexName,
+ IndexTimestamp = this.IndexTimestamp,
+ IsStale = this.IsStale,
+ SkippedResults = this.SkippedResults,
+ TotalResults = this.TotalResults,
+ Highlightings = this.Highlightings.ToDictionary(
+ pair => pair.Key,
+ x => new Dictionary<string, string[]>(x.Value))
+ };
}
}
}
View
3  Raven.Abstractions/Data/SpatialIndexQuery.cs
@@ -46,6 +46,9 @@ public SpatialIndexQuery(IndexQuery query) : this()
PageSize = query.PageSize;
FieldsToFetch = query.FieldsToFetch;
SortedFields = query.SortedFields;
+ HighlighterPreTags = query.HighlighterPreTags;
+ HighlighterPostTags = query.HighlighterPostTags;
+ HighlightedFields = query.HighlightedFields;
}
/// <summary>
View
66 Raven.Abstractions/Data/StringDistanceTypes.cs
@@ -1,30 +1,38 @@
-//-----------------------------------------------------------------------
-// <copyright file="StringDistanceTypes.cs" company="Hibernating Rhinos LTD">
-// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-namespace Raven.Abstractions.Data
-{
- /// <summary>
- /// String distance algorithms used in suggestion query
- /// </summary>
- public enum StringDistanceTypes
- {
- /// <summary>
- /// Default, equivalent to Levenshtein
- /// </summary>
- Default = 0,
- /// <summary>
- /// JaroWinkler distance algorithm
- /// </summary>
- JaroWinkler,
- /// <summary>
- /// Levenshtein distance algorithm (default)
- /// </summary>
- Levenshtein,
- /// <summary>
- /// NGram distance algorithm
- /// </summary>
- NGram,
- }
+//-----------------------------------------------------------------------
+// <copyright file="StringDistanceTypes.cs" company="Hibernating Rhinos LTD">
+// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+namespace Raven.Abstractions.Data
+{
+ /// <summary>
+ /// String distance algorithms used in suggestion query
+ /// </summary>
+ public enum StringDistanceTypes
+ {
+ /// <summary>
+ /// Default, suggestion is not active
+ /// </summary>
+ None,
+
+ /// <summary>
+ /// Default, equivalent to Levenshtein
+ /// </summary>
+ Default,
+
+ /// <summary>
+ /// Levenshtein distance algorithm (default)
+ /// </summary>
+ Levenshtein,
+
+ /// <summary>
+ /// JaroWinkler distance algorithm
+ /// </summary>
+ JaroWinkler,
+
+ /// <summary>
+ /// NGram distance algorithm
+ /// </summary>
+ NGram,
+ }
}
View
6 Raven.Abstractions/Data/SuggestionQuery.cs
@@ -16,6 +16,7 @@ public class SuggestionQuery
public SuggestionQuery()
{
MaxSuggestions = 15;
+ Distance = StringDistanceTypes.Default;
}
/// <summary>
@@ -23,26 +24,31 @@ public SuggestionQuery()
/// </summary>
/// <value>The term.</value>
public string Term { get; set; }
+
/// <summary>
/// Gets or sets the field to be used in conjunction with the index.
/// </summary>
/// <value>The field.</value>
public string Field { get; set; }
+
/// <summary>
/// Gets or sets the number of suggestions to return.
/// </summary>
/// <value>The number of suggestions.</value>
public int MaxSuggestions { get; set; }
+
/// <summary>
/// Gets or sets the string distance algorithm.
/// </summary>
/// <value>The distance.</value>
public StringDistanceTypes Distance { get; set; }
+
/// <summary>
/// Gets or sets the accuracy.
/// </summary>
/// <value>The accuracy.</value>
public float Accuracy { get; set; }
+
/// <summary>
/// Whatever to return the terms in order of popularity
/// </summary>
View
136 Raven.Abstractions/Exceptions/ConcurrencyException.cs
@@ -1,68 +1,68 @@
-//-----------------------------------------------------------------------
-// <copyright file="ConcurrencyException.cs" company="Hibernating Rhinos LTD">
-// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-using System;
-
-namespace Raven.Abstractions.Exceptions
-{
- /// <summary>
- /// This exception is raised when a concurrency conflict is encountered
- /// </summary>
-#if SILVERILGHT
- [Serializable]
-#endif
- public class ConcurrencyException : Exception
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="ConcurrencyException"/> class.
- /// </summary>
- public ConcurrencyException()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ConcurrencyException"/> class.
- /// </summary>
- /// <param name="message">The message.</param>
- public ConcurrencyException(string message) : base(message)
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ConcurrencyException"/> class.
- /// </summary>
- /// <param name="message">The message.</param>
- /// <param name="inner">The inner.</param>
- public ConcurrencyException(string message, Exception inner) : base(message, inner)
- {
- }
-
-#if SILERLIGHT
- /// <summary>
- /// Initializes a new instance of the <see cref="ConcurrencyException"/> class.
- /// </summary>
- /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
- /// <exception cref="T:System.ArgumentNullException">The <paramref name="info"/> parameter is null. </exception>
- /// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0). </exception>
- protected ConcurrencyException(
- SerializationInfo info,
- StreamingContext context) : base(info, context)
- {
- }
-#endif
-
- /// <summary>
- /// Gets or sets the expected E tag.
- /// </summary>
- /// <value>The expected E tag.</value>
- public Guid ExpectedETag { get; set; }
- /// <summary>
- /// Gets or sets the actual E tag.
- /// </summary>
- /// <value>The actual E tag.</value>
- public Guid ActualETag { get; set; }
- }
-}
+//-----------------------------------------------------------------------
+// <copyright file="ConcurrencyException.cs" company="Hibernating Rhinos LTD">
+// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+using System;
+
+namespace Raven.Abstractions.Exceptions
+{
+ /// <summary>
+ /// This exception is raised when a concurrency conflict is encountered
+ /// </summary>
+#if SILVERILGHT
+ [Serializable]
+#endif
+ public class ConcurrencyException : Exception
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ConcurrencyException"/> class.
+ /// </summary>
+ public ConcurrencyException()
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ConcurrencyException"/> class.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ public ConcurrencyException(string message) : base(message)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ConcurrencyException"/> class.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="inner">The inner.</param>
+ public ConcurrencyException(string message, Exception inner) : base(message, inner)
+ {
+ }
+
+#if SILERLIGHT
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ConcurrencyException"/> class.
+ /// </summary>
+ /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
+ /// <exception cref="T:System.ArgumentNullException">The <paramref name="info"/> parameter is null. </exception>
+ /// <exception cref="T:System.Runtime.Serialization.SerializationException">The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0). </exception>
+ protected ConcurrencyException(
+ SerializationInfo info,
+ StreamingContext context) : base(info, context)
+ {
+ }
+#endif
+
+ /// <summary>
+ /// Gets or sets the expected E tag.
+ /// </summary>
+ /// <value>The expected E tag.</value>
+ public Guid ExpectedETag { get; set; }
+ /// <summary>
+ /// Gets or sets the actual E tag.
+ /// </summary>
+ /// <value>The actual E tag.</value>
+ public Guid ActualETag { get; set; }
+ }
+}
View
48 Raven.Abstractions/Extensions/TaskExtensions.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Net;
+using System.Security;
+using System.Threading.Tasks;
+
+namespace Raven.Abstractions.Extensions
+{
+ public static class TaskExtensions
+ {
+ public static void AssertNotFailed(this Task task)
+ {
+ if (task.IsFaulted)
+ task.Wait(); // would throw
+ }
+
+ public static Task<T> ConvertSecurityExceptionToServerNotFound<T>(this Task<T> parent)
+ {
+ return parent.ContinueWith(task =>
+ {
+ if (task.IsFaulted)
+ {
+ var exception = task.Exception.ExtractSingleInnerException();
+ if (exception is SecurityException)
+ throw new WebException("Could not contact server.\r\nGot security error because RavenDB wasn't able to contact the database to get ClientAccessPolicy.xml permission.", exception);
+ }
+ return task;
+ }).Unwrap();
+ }
+
+
+ public static Task<T> AddUrlIfFaulting<T>(this Task<T> parent, Uri uri)
+ {
+ return parent.ContinueWith(task =>
+ {
+ if (task.IsFaulted)
+ {
+ var e = task.Exception.ExtractSingleInnerException();
+ if (e != null)
+ e.Data["Url"] = uri;
+ }
+
+ return task;
+ })
+ .Unwrap();
+ }
+
+ }
+}
View
30 Raven.Abstractions/Indexing/FieldTermVector.cs
@@ -0,0 +1,30 @@
+namespace Raven.Abstractions.Indexing
+{
+ /// <summary>
+ /// Specifies whether to include term vectors for a field
+ /// </summary>
+ public enum FieldTermVector
+ {
+ /// <summary>
+ /// Do not store term vectors
+ /// </summary>
+ No,
+ /// <summary>
+ /// Store the term vectors of each document. A term vector is a list of the document's
+ /// terms and their number of occurrences in that document.
+ /// </summary>
+ Yes,
+ /// <summary>
+ /// Store the term vector + token position information
+ /// </summary>
+ WithPositions,
+ /// <summary>
+ /// Store the term vector + Token offset information
+ /// </summary>
+ WithOffsets,
+ /// <summary>
+ /// Store the term vector + Token position and offset information
+ /// </summary>
+ WithPositionsAndOffsets
+ }
+}
View
45 Raven.Abstractions/Indexing/IndexDefinition.cs
@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Raven.Abstractions.Data;
namespace Raven.Abstractions.Indexing
{
@@ -25,6 +26,8 @@ public IndexDefinition()
Analyzers = new Dictionary<string, string>();
SortOptions = new Dictionary<string, SortOptions>();
Fields = new List<string>();
+ Suggestions = new Dictionary<string, SuggestionOptions>();
+ TermVectors = new Dictionary<string, FieldTermVector>();
}
/// <summary>
@@ -118,6 +121,18 @@ public bool IsTemp
public IList<string> Fields { get; set; }
/// <summary>
+ /// Gets or sets the suggest options
+ /// </summary>
+ /// <value>The suggest options.</value>
+ public IDictionary<string, SuggestionOptions> Suggestions { get; set; }
+
+ /// <summary>
+ /// Gets or sets the term vectors options
+ /// </summary>
+ /// <value>The term vectors.</value>
+ public IDictionary<string, FieldTermVector> TermVectors { get; set; }
+
+ /// <summary>
/// Equals the specified other.
/// </summary>
/// <param name="other">The other.</param>
@@ -129,13 +144,15 @@ public bool Equals(IndexDefinition other)
if (ReferenceEquals(this, other))
return true;
return Maps.SequenceEqual(other.Maps) &&
- Equals(other.Name, Name) &&
- Equals(other.Reduce, Reduce) &&
- Equals(other.TransformResults, TransformResults) &&
- DictionaryEquals(other.Stores, Stores) &&
- DictionaryEquals(other.Indexes, Indexes) &&
- DictionaryEquals(other.Analyzers, Analyzers) &&
- DictionaryEquals(other.SortOptions, SortOptions);
+ Equals(other.Name, Name) &&
+ Equals(other.Reduce, Reduce) &&
+ Equals(other.TransformResults, TransformResults) &&
+ DictionaryEquals(other.Stores, Stores) &&
+ DictionaryEquals(other.Indexes, Indexes) &&
+ DictionaryEquals(other.Analyzers, Analyzers) &&
+ DictionaryEquals(other.SortOptions, SortOptions) &&
+ DictionaryEquals(other.Suggestions, Suggestions) &&
+ DictionaryEquals(other.TermVectors, TermVectors);
}
private static bool DictionaryEquals<TKey, TValue>(IDictionary<TKey, TValue> x, IDictionary<TKey, TValue> y)
@@ -216,6 +233,8 @@ public override int GetHashCode()
result = (result * 397) ^ DictionaryHashCode(Indexes);
result = (result * 397) ^ DictionaryHashCode(Analyzers);
result = (result * 397) ^ DictionaryHashCode(SortOptions);
+ result = (result * 397) ^ DictionaryHashCode(Suggestions);
+ result = (result * 397) ^ DictionaryHashCode(TermVectors);
return result;
}
}
@@ -259,6 +278,14 @@ public void RemoveDefaultValues()
{
Analyzers.Remove(toRemove);
}
+ foreach (var toRemove in Suggestions.Where(x => x.Value.Distance == StringDistanceTypes.None).ToArray())
+ {
+ Suggestions.Remove(toRemove);
+ }
+ foreach (var toRemove in TermVectors.Where(x => x.Value == FieldTermVector.No).ToArray())
+ {
+ TermVectors.Remove(toRemove);
+ }
}
public IndexDefinition Clone()
@@ -283,6 +310,10 @@ public IndexDefinition Clone()
indexDefinition.SortOptions = new Dictionary<string, SortOptions>(SortOptions);
if (Stores != null)
indexDefinition.Stores = new Dictionary<string, FieldStorage>(Stores);
+ if (Suggestions != null)
+ indexDefinition.Suggestions = new Dictionary<string, SuggestionOptions>(Suggestions);
+ if (TermVectors != null)
+ indexDefinition.TermVectors = new Dictionary<string, FieldTermVector>(TermVectors);
return indexDefinition;
}
}
View
19 Raven.Abstractions/Indexing/SuggestionOptions.cs
@@ -0,0 +1,19 @@
+using Raven.Abstractions.Data;
+
+namespace Raven.Abstractions.Indexing
+{
+ public class SuggestionOptions
+ {
+ /// <summary>
+ /// Gets or sets the string distance algorithm.
+ /// </summary>
+ /// <value>The distance. The default value is StringDistanceTypes.Levenshtein.</value>
+ public StringDistanceTypes Distance { get; set; }
+
+ /// <summary>
+ /// Gets or sets the accuracy.
+ /// </summary>
+ /// <value>The accuracy. The default value is 0.5f.</value>
+ public float Accuracy { get; set; }
+ }
+}
View
87 Raven.Abstractions/Json/Linq/DictionaryWithParentSnapshot.cs
@@ -12,7 +12,7 @@ internal class DictionaryWithParentSnapshot : IDictionary<string, RavenJToken>
private static readonly RavenJToken DeletedMarker = new RavenJValue("*DeletedMarker*", JTokenType.Null);
private readonly DictionaryWithParentSnapshot parentSnapshot;
- private int count = -1;
+ private int count;
private IDictionary<string, RavenJToken> localChanges;
private string snapshotMsg;
@@ -20,7 +20,7 @@ internal class DictionaryWithParentSnapshot : IDictionary<string, RavenJToken>
{
get
{
- if(localChanges == null)
+ if (localChanges == null)
localChanges = new Dictionary<string, RavenJToken>(comparer);
return localChanges;
}
@@ -47,7 +47,7 @@ public void Add(string key, RavenJToken value)
if (ContainsKey(key))
throw new ArgumentException(string.Format("An item with the same key has already been added: '{0}'", key));
- count = -1;
+ count += 1;
LocalChanges[key] = value; // we can't use Add, because LocalChanges may contain a DeletedMarker
}
@@ -71,13 +71,11 @@ public ICollection<string> Keys
{
if (parentSnapshot != null)
{
- if (count == -1) count = parentSnapshot.count;
return parentSnapshot.Keys;
}
return new HashSet<string>();
}
- int counter = 0;
ICollection<string> ret = new HashSet<string>();
if (parentSnapshot != null)
{
@@ -86,7 +84,6 @@ public ICollection<string> Keys
if (LocalChanges.ContainsKey(key))
continue;
ret.Add(key);
- ++counter;
}
}
@@ -97,10 +94,8 @@ public ICollection<string> Keys
value == DeletedMarker)
continue;
ret.Add(key);
- ++counter;
}
- count = counter;
return ret;
}
}
@@ -110,22 +105,27 @@ public bool Remove(string key)
if (IsSnapshot)
throw new InvalidOperationException("Cannot modify a snapshot, this is probably a bug");
- count = -1;
- RavenJToken token;
- if (!LocalChanges.TryGetValue(key, out token))
- {
- bool parentHasIt = parentSnapshot == null || parentSnapshot.TryGetValue(key, out token);
- if (parentHasIt == false)
- return false;
+ RavenJToken parentToken = null;
- if (token == DeletedMarker)
- return false;
+ bool parentHasIt = parentSnapshot != null &&
+ parentSnapshot.TryGetValue(key, out parentToken);
- LocalChanges[key] = DeletedMarker;
- return true;
+ RavenJToken token;
+ if (LocalChanges.TryGetValue(key, out token) == false)
+ {
+ if (parentHasIt && parentToken != DeletedMarker)
+ {
+ LocalChanges[key] = DeletedMarker;
+ count -= 1;
+ return true;
+ }
+ return false;
}
-
- return LocalChanges.Remove(key);
+ if (token == DeletedMarker)
+ return false;
+ count -= 1;
+ LocalChanges[key] = DeletedMarker;
+ return true;
}
public bool TryGetValue(string key, out RavenJToken value)
@@ -141,10 +141,18 @@ public bool TryGetValue(string key, out RavenJToken value)
return true;
}
- if (parentSnapshot == null || !parentSnapshot.TryGetValue(key, out unsafeVal) || unsafeVal == DeletedMarker)
+ if (parentSnapshot == null ||
+ !parentSnapshot.TryGetValue(key, out unsafeVal) ||
+ unsafeVal == DeletedMarker)
return false;
- value = unsafeVal;
+ if (IsSnapshot == false && unsafeVal != null)
+ {
+ if (unsafeVal.IsSnapshot == false && unsafeVal.Type != JTokenType.Object)
+ unsafeVal.EnsureCannotBeChangeAndEnableSnapshotting();
+ }
+
+ value = unsafeVal;
return true;
}
@@ -173,10 +181,12 @@ public ICollection<RavenJToken> Values
}
set
{
- count = -1;
- if(IsSnapshot)
+ if (IsSnapshot)
throw new InvalidOperationException("Cannot modify a snapshot, this is probably a bug");
+ var isInsert = ContainsKey(key) == false;
LocalChanges[key] = value;
+ if (isInsert)
+ count += 1;
}
}
@@ -184,22 +194,22 @@ public ICollection<RavenJToken> Values
public IEnumerator<KeyValuePair<string, RavenJToken>> GetEnumerator()
{
- if(parentSnapshot != null)
+ if (parentSnapshot != null)
{
foreach (var item in parentSnapshot)
{
- if(LocalChanges.ContainsKey(item.Key))
+ if (LocalChanges.ContainsKey(item.Key))
continue;
yield return item;
}
}
- foreach (var localChange in LocalChanges)
- {
- if(localChange.Value == DeletedMarker)
+ foreach (var localChange in LocalChanges)
+ {
+ if (localChange.Value == DeletedMarker)
continue;
- yield return localChange;
- }
-
+ yield return localChange;
+ }
+
}
IEnumerator IEnumerable.GetEnumerator()
@@ -229,7 +239,7 @@ public bool Contains(KeyValuePair<string, RavenJToken> item)
public void CopyTo(KeyValuePair<string, RavenJToken>[] array, int arrayIndex)
{
- if(parentSnapshot != null)
+ if (parentSnapshot != null)
{
parentSnapshot.CopyTo(array, arrayIndex);
arrayIndex += parentSnapshot.Count;
@@ -244,7 +254,12 @@ public bool Remove(KeyValuePair<string, RavenJToken> item)
public int Count
{
- get { return (count >= 0) ? count : Keys.Count; }
+ get
+ {
+ if (parentSnapshot != null)
+ return count + parentSnapshot.Count;
+ return count;
+ }
}
public bool IsReadOnly
@@ -257,7 +272,7 @@ public bool IsReadOnly
public DictionaryWithParentSnapshot CreateSnapshot()
{
- if(IsSnapshot == false)
+ if (IsSnapshot == false)
throw new InvalidOperationException("Cannot create snapshot without previously calling EnsureSnapShot");
return new DictionaryWithParentSnapshot(this);
}
View
17 Raven.Abstractions/Json/Linq/RavenJArray.cs
@@ -33,8 +33,11 @@ public RavenJArray()
public RavenJArray(IEnumerable content)
{
Items = new List<RavenJToken>();
+ if (content == null)
+ return;
+
var ravenJToken = content as RavenJToken;
- if (ravenJToken != null)
+ if (ravenJToken != null && ravenJToken.Type != JTokenType.Array)
{
Items.Add(ravenJToken);
}
@@ -61,7 +64,10 @@ public RavenJArray(params object[] content)
public RavenJArray(IEnumerable<RavenJToken> content)
{
Items = new List<RavenJToken>();
- Items.AddRange(content);
+ if (content != null)
+ {
+ Items.AddRange(content);
+ }
}
/// <summary>
@@ -94,6 +100,11 @@ public override RavenJToken CloneToken()
return CloneTokenImpl(new RavenJArray());
}
+ public override bool IsSnapshot
+ {
+ get { return isSnapshot; }
+ }
+
public int Length { get { return Items.Count; } }
private List<RavenJToken> Items { get; set; }
@@ -258,7 +269,7 @@ internal override void AddForCloning(string key, RavenJToken token)
Add(token);
}
- public override void EnsureSnapshot()
+ public override void EnsureCannotBeChangeAndEnableSnapshotting()
{
isSnapshot = true;
}
View
5 Raven.Abstractions/Json/Linq/RavenJObject.cs
@@ -48,7 +48,8 @@ public ICollection<string> Keys
{
get { return Properties.Keys; }
}
- public bool IsSnapshot
+
+ public override bool IsSnapshot
{
get { return Properties.IsSnapshot; }
}
@@ -333,7 +334,7 @@ public override RavenJToken CreateSnapshot()
return new RavenJObject(Properties.CreateSnapshot());
}
- public override void EnsureSnapshot()
+ public override void EnsureCannotBeChangeAndEnableSnapshotting()
{
Properties.EnsureSnapshot();
}
View
4 Raven.Abstractions/Json/Linq/RavenJToken.cs
@@ -28,7 +28,9 @@ public abstract class RavenJToken
/// <returns>A cloned RavenJToken</returns>
public abstract RavenJToken CloneToken();
- public abstract void EnsureSnapshot();
+ public abstract bool IsSnapshot { get; }
+
+ public abstract void EnsureCannotBeChangeAndEnableSnapshotting();
public abstract RavenJToken CreateSnapshot();
View
14 Raven.Abstractions/Json/Linq/RavenJTokenEqualityComparer.cs
@@ -5,8 +5,10 @@ namespace Raven.Json.Linq
/// <summary>
/// Compares tokens to determine whether they are equal.
/// </summary>
- public class RavenJTokenEqualityComparer : IEqualityComparer<RavenJToken>
+ public class RavenJTokenEqualityComparer : IEqualityComparer<RavenJToken>, IEqualityComparer<object>
{
+ public readonly static RavenJTokenEqualityComparer Default = new RavenJTokenEqualityComparer();
+
/// <summary>
/// Determines whether the specified objects are equal.
/// </summary>
@@ -33,5 +35,15 @@ public int GetHashCode(RavenJToken obj)
return obj.GetDeepHashCode();
}
+
+ public bool Equals(object x, object y)
+ {
+ return this.Equals((RavenJToken) x, (RavenJToken) y);
+ }
+
+ public int GetHashCode(object obj)
+ {
+ return GetHashCode((RavenJToken) obj);
+ }
}
}
View
4 Raven.Abstractions/Json/Linq/RavenJTokenReader.cs
@@ -422,6 +422,10 @@ private static JsonToken GetJsonTokenType(RavenJToken token)
return JsonToken.Bytes;
case JTokenType.Guid:
return JsonToken.String;
+ case JTokenType.TimeSpan:
+ return JsonToken.String;
+ case JTokenType.Uri:
+ return JsonToken.String;
default:
throw MiscellaneousUtils.CreateArgumentOutOfRangeException("Type", token.Type, "Unexpected JTokenType.");
}
View
7 Raven.Abstractions/Json/Linq/RavenJValue.cs
@@ -59,6 +59,11 @@ public override RavenJToken CloneToken()
return new RavenJValue(Value, Type);
}
+ public override bool IsSnapshot
+ {
+ get { return isSnapshot; }
+ }
+
/// <summary>
/// Initializes a new instance of the <see cref="RavenJValue"/> class with the given value.
/// </summary>
@@ -630,7 +635,7 @@ public string ToString(string format, IFormatProvider formatProvider)
return _value.ToString();
}
- public override void EnsureSnapshot()
+ public override void EnsureCannotBeChangeAndEnableSnapshotting()
{
isSnapshot = true;
}
View
44 Raven.Abstractions/Linq/DynamicJsonObject.cs
@@ -120,9 +120,14 @@ public override bool TryGetMember(GetMemberBinder binder, out object result)
public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
{
- if(binder.Name == "Value" && args.Length == 1 && args[0] is string)
+ if (binder.Name == "Count" && args.Length == 0)
{
- result = GetValue((string) args[0]);
+ result = inner.Count;
+ return true;
+ }
+ if (binder.Name == "Value" && args.Length == 1 && args[0] is string)
+ {
+ result = GetValue((string)args[0]);
return true;
}
return base.TryInvokeMember(binder, args, out result);
@@ -151,7 +156,7 @@ public object TransformToValue(RavenJToken jToken)
{
case JTokenType.Object:
var jObject = (RavenJObject)jToken;
- if(jObject.ContainsKey("$values"))
+ if (jObject.ContainsKey("$values"))
{
var values = jObject.Value<RavenJArray>("$values");
return new DynamicList(this, values.Select(TransformToValue).ToArray());
@@ -168,7 +173,7 @@ public object TransformToValue(RavenJToken jToken)
var ar = (RavenJArray)jToken;
return new DynamicList(this, ar.Select(TransformToValue).ToArray());
case JTokenType.Date:
- var ravenJValue = ((RavenJValue) jToken);
+ var ravenJValue = ((RavenJValue)jToken);
return ravenJValue.Value;
case JTokenType.Null:
return new DynamicNullObject { IsExplicitNull = true };
@@ -180,7 +185,7 @@ public object TransformToValue(RavenJToken jToken)
if (l > int.MinValue && int.MaxValue > l)
return (int)l;
}
- if(value is Guid)
+ if (value is Guid)
{
return value.ToString();
}
@@ -188,18 +193,18 @@ public object TransformToValue(RavenJToken jToken)
if (s != null)
{
//optimizations, don't try to call TryParse if empty
- if(s.Length == 0)
+ if (s.Length == 0)
return s;
- //optimizations, don't try to call TryParse if first char isn't a digit
- if(char.IsDigit(s[0]) == false)
+ //optimizations, don't try to call TryParse if first char isn't a digit or '-'
+ if (char.IsDigit(s[0]) == false && s[0] != '-')
return s;
DateTime dateTime;
if (DateTime.TryParseExact(s, Default.OnlyDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out dateTime))
{
- if(s.EndsWith("Z"))
+ if (s.EndsWith("Z"))
return DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
return dateTime;
}
@@ -208,6 +213,13 @@ public object TransformToValue(RavenJToken jToken)
{
return dateTimeOffset;
}
+ TimeSpan timeSpan;
+ if (s.Contains(":") &&
+ TimeSpan.TryParseExact(s,"c", CultureInfo.InvariantCulture, out timeSpan))
+ {
+ return timeSpan;
+ }
+
}
return value ?? new DynamicNullObject { IsExplicitNull = true };
}
@@ -215,11 +227,15 @@ public object TransformToValue(RavenJToken jToken)
private RavenJObject FindReference(string refId)
{
+ return GetRootParentOrSelf().Scan().FirstOrDefault(x => x.Value<string>("$id") == refId);
+ }
+
+ public DynamicJsonObject GetRootParentOrSelf()
+ {
var p = this;
while (p.parent != null)
p = p.parent;
-
- return p.Scan().FirstOrDefault(x => x.Value<string>("$id") == refId);
+ return p;
}
private IEnumerable<RavenJObject> Scan()
@@ -289,7 +305,7 @@ public object GetValue(string name)
{
if (name == Constants.DocumentIdFieldName)
{
- return GetDocumentId();
+ return GetRootParentOrSelf().GetDocumentId();
}
RavenJToken value;
if (inner.TryGetValue(name, out value))
@@ -305,13 +321,13 @@ public object GetValue(string name)
}
if (name == "Id")
{
- return GetDocumentId();
+ return GetRootParentOrSelf().GetDocumentId();
}
if (name == "Inner")
{
return inner;
}
- if(name == "Count" || name == "Count()")
+ if (name == "Count" || name == "Count()")
{
return inner.Count;
}
View
3  Raven.Abstractions/Logging/LogManager.cs
@@ -64,6 +64,9 @@ private static ILogManager ResolveExternalLogManager()
public static void RegisterTarget<T>() where T: Target, new()
{
+ if (targets.OfType<T>().Any())
+ return;
+
targets.Add(new T());
}
View
4 ...ghtweight/Document/OAuth/AbstractAuthenticator.cs → Raven.Abstractions/OAuth/AbstractAuthenticator.cs
@@ -1,8 +1,8 @@
using System;
using System.Net;
-using Raven.Client.Connection;
+using Raven.Abstractions.Connection;
-namespace Raven.Client.Document.OAuth
+namespace Raven.Abstractions.OAuth
{
public abstract class AbstractAuthenticator
{
View
61 ...ightweight/Document/OAuth/SecuredAuthenticator.cs → Raven.Abstractions/OAuth/SecuredAuthenticator.cs
@@ -1,18 +1,20 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
using System.Net;
-#if SILVERLIGHT
-using System.Net.Browser;
-#endif
using System.Threading.Tasks;
using Raven.Abstractions.Connection;
using System.Linq;
using Raven.Abstractions.Extensions;
using Raven.Abstractions.Util;
-using Raven.Client.Extensions;
+#if SILVERLIGHT
+using System.Net.Browser;
+using Raven.Client.Changes;
+
+#endif