Пример #1
0
 protected override void OnModified(object sender, NodeEventArgs e)
 {
     //Debug.WriteLine(String.Format("##WF> WorkflowHandlerBase.OnModified: {0}, {1}, {2}", Id, WorkflowInstanceGuid, Path));
     base.OnModified(sender, e);
     if (e.ChangedData.Any(x => x.Name == WORKFLOWSTATUS))
     {
         // elevation: we need to act here anyway, regardless of the current users permissions
         using (new SystemAccount())
         {
             string wfDefVer;
             var    wfDef = LoadWorkflowDefinition(out wfDefVer);
             if (Node.Exists(this.Path) && !TrashBin.IsInTrash(this)
                 &&
                 (
                     (wfDef.DeleteInstanceAfterFinished == WorkflowDeletionStrategy.DeleteWhenCompleted && this.WorkflowStatus == WorkflowStatusEnum.Completed)
                     ||
                     (wfDef.DeleteInstanceAfterFinished == WorkflowDeletionStrategy.DeleteWhenCompletedOrAborted &&
                      (this.WorkflowStatus == WorkflowStatusEnum.Completed || this.WorkflowStatus == WorkflowStatusEnum.Aborted))
                 ))
             {
                 ForceDelete();
             }
         }
     }
 }
Пример #2
0
        private bool ContentsAreInTrash()
        {
            if (RequestIdList.Count == 0)
            {
                return(TrashBin.IsInTrash(ContextNode as GenericContent));
            }

            return(RequestNodeList.Count(n => TrashBin.IsInTrash(n as GenericContent)) > 0);
        }
Пример #3
0
 public override void Delete()
 {
     //Debug.WriteLine(String.Format("##WF> WorkflowHandlerBase.Delete: {0}, {1}, {2}", Id, WorkflowInstanceGuid, Path));
     if (WorkflowStatus == WorkflowStatusEnum.Running)
     {
         InstanceManager.Abort(this, WorkflowApplicationAbortReason.StateContentDeleted);
     }
     if (!TrashBin.IsInTrash(this))
     {
         base.Delete();
     }
 }
Пример #4
0
 public override void Delete()
 {
     SnTrace.Workflow.Write("WorkflowHandlerBase.Delete: {0}, {1}, {2}", Id, WorkflowInstanceGuid, Path);
     if (WorkflowStatus == WorkflowStatusEnum.Running)
     {
         InstanceManager.Abort(this, WorkflowApplicationAbortReason.StateContentDeleted);
     }
     if (!TrashBin.IsInTrash(this))
     {
         base.Delete();
     }
 }
Пример #5
0
        public override IEnumerable <IndexFieldInfo> GetIndexFieldInfos(ContentRepository.Field snField, out string textExtract)
        {
            textExtract = String.Empty;

            var content   = snField.Content;
            var boolValue = false;

            //check Trash
            if (TrashBin.IsInTrash(content.ContentHandler as GenericContent))
            {
                boolValue = true;
            }

            //check SystemFile
            if (!boolValue)
            {
                if (content.ContentHandler.NodeType.IsInstaceOfOrDerivedFrom("SystemFile"))
                {
                    boolValue = true;
                }
            }

            //check SystemFolder
            if (!boolValue)
            {
                var parent = content.ContentHandler;

                using (new SystemAccount())
                {
                    while (parent != null)
                    {
                        if (parent.NodeType.IsInstaceOfOrDerivedFrom("SystemFolder"))
                        {
                            boolValue = true;
                            break;
                        }

                        parent = parent.Parent;
                    }
                }
            }

            return(CreateFieldInfo(snField.Name, boolValue ? BooleanIndexHandler.YES : BooleanIndexHandler.NO));
        }
Пример #6
0
        public override IEnumerable <string> GetParsableValues(SnCR.Field snField)
        {
            var content   = snField.Content;
            var boolValue = false;

            //check Trash
            if (TrashBin.IsInTrash(content.ContentHandler as GenericContent))
            {
                boolValue = true;
            }

            //check SystemFile
            if (!boolValue)
            {
                if (content.ContentHandler.NodeType.IsInstaceOfOrDerivedFrom("SystemFile"))
                {
                    boolValue = true;
                }
            }

            //check SystemFolder
            if (!boolValue)
            {
                var parent = content.ContentHandler;

                using (new SystemAccount())
                {
                    while (parent != null)
                    {
                        if (parent.NodeType.IsInstaceOfOrDerivedFrom("SystemFolder"))
                        {
                            boolValue = true;
                            break;
                        }

                        parent = parent.Parent;
                    }
                }
            }

            return(new[] { boolValue?BooleanIndexHandler.YES : BooleanIndexHandler.NO });
        }
Пример #7
0
        private async Task DeleteByAction(string body, bool permanent)
        {
            // workaround: remove the old Delete application that is
            // not compatible with the .net core method
            var deleteAppPath = "/Root/(apps)/GenericContent/Delete";

            if (Node.Exists(deleteAppPath))
            {
                Node.ForceDelete(deleteAppPath);
            }

            // ARRANGE
            var testRoot = CreateTestRoot("ODataTestRoot");
            var name     = "Content1";
            var content  = Content.CreateNew("File", testRoot, name);

            content.Save();
            var repoPath = $"{testRoot.Path}/{name}";
            var resource = $"/OData.svc/{testRoot.Path}('{name}')/Delete";

            // ACTION
            var response = await ODataPostAsync(resource, "", body).ConfigureAwait(false);

            // ASSERT
            AssertNoError(response);
            Assert.IsFalse(Node.Exists(repoPath));

            // reload
            content = Content.Load(content.Id);

            if (permanent)
            {
                Assert.IsNull(content);
            }
            else
            {
                Assert.IsTrue(TrashBin.IsInTrash(content.ContentHandler as GenericContent));
            }
        }
        internal MembershipExtension GetSharingExtension(string contextValue)
        {
            // check the url first
            var sharingGroup = GetSharingGroupByUrlParameter()?.ContentHandler as Group;

            // check the context param next
            if (sharingGroup == null && contextValue != null)
            {
                sharingGroup = SharingHandler.GetSharingGroupBySharingId(contextValue)?.ContentHandler as Group;
            }

            if (sharingGroup == null)
            {
                return(MembershipExtension.Placeholder);
            }

            var sharedNode = sharingGroup.GetReference <GenericContent>(Constants.SharedContentFieldName);

            // Check if the related shared content exists.
            if (sharedNode == null)
            {
                // Invalid sharing group: no related content. Delete the group and move on.
                SnTrace.Security.Write($"SharingMembershipExtender: Deleting orphaned sharing group {sharingGroup.Id} ({sharingGroup.Path}).");

                sharingGroup.ForceDelete();
                sharingGroup = null;
            }

            // If found and the content is not in the Trash, return a new extension collection
            // containing the sharing group.
            if ((sharingGroup?.ContentType.IsInstaceOfOrDerivedFrom(Constants.SharingGroupTypeName) ?? false) &&
                !TrashBin.IsInTrash(sharedNode))
            {
                return(new MembershipExtension(new[] { sharingGroup.Id }));
            }

            return(MembershipExtension.Placeholder);
        }