Esempio n. 1
0
 public override ReadVetoResult AllowRead(string key, Json.Linq.RavenJObject metadata, ReadOperation operation, Abstractions.Data.TransactionInformation transactionInformation)
 {
     if (operation == ReadOperation.Index && metadata.ContainsKey(Constants.RavenReplicationConflictDocument))
     {
         return(ReadVetoResult.Ignore);
     }
     return(ReadVetoResult.Allowed);
 }
        public override VetoResult AllowPut(string key, Json.Linq.RavenJObject document, Json.Linq.RavenJObject metadata, Abstractions.Data.TransactionInformation transactionInformation)
        {
            if (metadata.ContainsKey(Constants.RavenReplicationConflictDocument) && metadata.ContainsKey(Constants.RavenReplicationConflictDocumentForcePut) == false)
            {
                return(VetoResult.Deny("You cannot PUT a document with metadata " + Constants.RavenReplicationConflictDocument));
            }
            JsonDocument documentByKey = null;

            Database.TransactionalStorage.Batch(accessor =>
            {
                documentByKey = accessor.Documents.DocumentByKey(key);
            });
            if (documentByKey == null)
            {
                return(VetoResult.Allowed);
            }
            if (documentByKey.Metadata.ContainsKey(Constants.RavenReplicationConflictDocument))
            {
                return(VetoResult.Deny("Conflict documents (with " + Constants.RavenReplicationConflictDocument +
                                       ") are read only and can only be modified by RavenDB when you resolve the conflict"));
            }
            return(VetoResult.Allowed);
        }