Beispiel #1
0
        private void InitializeTriggers()
        {
            PutTriggers
            .Init(disableAllTriggers)
            .OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));
            DeleteTriggers
            .Init(disableAllTriggers)
            .OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));
            ReadTriggers
            .Init(disableAllTriggers)
            .OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));

            AttachmentPutTriggers
            .Init(disableAllTriggers)
            .OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));
            AttachmentDeleteTriggers
            .Init(disableAllTriggers)
            .OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));
            AttachmentReadTriggers
            .Init(disableAllTriggers)
            .OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));

            IndexUpdateTriggers
            .Init(disableAllTriggers)
            .OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));
        }
Beispiel #2
0
        private void AssertAttachmentDeleteOperationNotVetoed(string key)
        {
            var vetoResult = AttachmentDeleteTriggers
                             .Select(trigger => new { Trigger = trigger, VetoResult = trigger.AllowDelete(key) })
                             .FirstOrDefault(x => x.VetoResult.IsAllowed == false);

            if (vetoResult != null)
            {
                throw new OperationVetoedException("DELETE vetoed by " + vetoResult.Trigger + " because: " + vetoResult.VetoResult.Reason);
            }
        }
Beispiel #3
0
 private void SecondStageInitialization()
 {
     DocumentCodecs
     .OfType <IRequiresDocumentDatabaseInitialization>()
     .Concat(PutTriggers.OfType <IRequiresDocumentDatabaseInitialization>())
     .Concat(DeleteTriggers.OfType <IRequiresDocumentDatabaseInitialization>())
     .Concat(IndexCodecs.OfType <IRequiresDocumentDatabaseInitialization>())
     .Concat(IndexQueryTriggers.OfType <IRequiresDocumentDatabaseInitialization>())
     .Concat(AttachmentPutTriggers.OfType <IRequiresDocumentDatabaseInitialization>())
     .Concat(AttachmentDeleteTriggers.OfType <IRequiresDocumentDatabaseInitialization>())
     .Concat(AttachmentReadTriggers.OfType <IRequiresDocumentDatabaseInitialization>())
     .Concat(IndexUpdateTriggers.OfType <IRequiresDocumentDatabaseInitialization>())
     .Apply(initialization => initialization.SecondStageInit());
 }
Beispiel #4
0
        public void DeleteStatic(string name, Guid?etag)
        {
            TransactionalStorage.Batch(actions =>
            {
                AssertAttachmentDeleteOperationNotVetoed(name);

                AttachmentDeleteTriggers.Apply(x => x.OnDelete(name));

                actions.Attachments.DeleteAttachment(name, etag);

                AttachmentDeleteTriggers.Apply(x => x.AfterDelete(name));

                workContext.ShouldNotifyAboutWork();
            });

            TransactionalStorage
            .ExecuteImmediatelyOrRegisterForSyncronization(
                () => AttachmentDeleteTriggers.Apply(trigger => trigger.AfterCommit(name)));
        }
Beispiel #5
0
        private void InitializeTriggersExceptIndexCodecs()
        {
            DocumentCodecs // .Init(disableAllTriggers) // Document codecs should always be activated (RavenDB-576)
            .OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));

            PutTriggers.Init(disableAllTriggers).OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));

            DeleteTriggers.Init(disableAllTriggers).OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));

            ReadTriggers.Init(disableAllTriggers).OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));

            IndexQueryTriggers.Init(disableAllTriggers).OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));

            AttachmentPutTriggers.Init(disableAllTriggers).OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));

            AttachmentDeleteTriggers.Init(disableAllTriggers).OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));

            AttachmentReadTriggers.Init(disableAllTriggers).OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));

            IndexUpdateTriggers.Init(disableAllTriggers).OfType <IRequiresDocumentDatabaseInitialization>().Apply(initialization => initialization.Initialize(this));
        }