public IEnumerable<EntityToken> GetParents(EntityToken entityToken)
        {
            if (entityToken is GeneratedDataTypesElementProviderRootEntityToken)
            {
                yield break;
            }
            else if (entityToken is GeneratedDataTypesElementProviderTypeEntityToken)
            {
                GeneratedDataTypesElementProviderTypeEntityToken castedToken = entityToken as GeneratedDataTypesElementProviderTypeEntityToken;

                Type type = TypeManager.TryGetType(castedToken.SerializedTypeName);

                if (type != null)
                {
                    yield return new GeneratedDataTypesElementProviderRootEntityToken(entityToken.Source, castedToken.Id);
                }
                else
                {
                    yield return null;
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            string currentConsoleId = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>().CurrentConsoleId;

            string serializedEntityToken = EntityTokenSerializer.Serialize(entityToken);

            if (actionToken.Serialize() == "ShowGraph")
            {
                string url = string.Format("{0}?EntityToken={1}", UrlUtils.ResolveAdminUrl("content/views/relationshipgraph/Default.aspx"), System.Web.HttpUtility.UrlEncode(serializedEntityToken));

                ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem { Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = "Show graph..." }, currentConsoleId);
            }
            else if (actionToken.Serialize() == "ShowOrientedGraph")
            {
                
                Guid id = Guid.NewGuid();
                string filename = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.TempDirectory), string.Format("{0}.RelationshipGraph", id));
                C1File.WriteAllLines(filename, new string[] { serializedEntityToken });

                string url = string.Format("{0}?Id={1}", UrlUtils.ResolveAdminUrl("content/views/relationshipgraph/ShowRelationshipOrientedGraph.aspx"), id);

                ConsoleMessageQueueFacade.Enqueue(new OpenViewMessageQueueItem { Url = url, ViewId = Guid.NewGuid().ToString(), ViewType = ViewType.Main, Label = "Show graph..." }, currentConsoleId);
            }

            return null;
        }
 public IEnumerable<ElementAction> GetActions(EntityToken entityToken)
 {
     if (entityToken == null || !(entityToken is PageElementProviderEntityToken))
     {
         return EmptyActionList;
     }
     
     return new[] {new ElementAction(new ActionHandle(new LinkCheckerActionToken()))
     {
         VisualData = new ActionVisualizedData
         {
             Label = GetResourceString("LinkCheckerActionToken.Label"),
             ToolTip = GetResourceString("LinkCheckerActionToken.ToolTip"),
             Icon = LinkIcon,
             Disabled = false,
             ActionLocation = new ActionLocation
             {
                 ActionType = ActionType.Other,
                 IsInFolder = false,
                 IsInToolbar = true,
                 ActionGroup = ViewActionGroup
             }
         }
     }};
 }
        public IEnumerable<EntityToken> GetParents(EntityToken entityToken)
        {
            WebsiteFileElementProviderEntityToken castedEntityToken = (WebsiteFileElementProviderEntityToken)entityToken;

            if ((C1File.Exists(castedEntityToken.Path) == false) &&
                (C1Directory.Exists(castedEntityToken.Path) == false))
            {
                return null;
            }

            string newFolderPath = Path.GetDirectoryName(castedEntityToken.Path);

            string rootFolder = castedEntityToken.RootPath;

            if (newFolderPath != rootFolder)
            {
                Verify.That(newFolderPath.Length > rootFolder.Length, 
                            "File/folder path '{0}' does not much root folder '{1}'",
                            newFolderPath, rootFolder);

                return new EntityToken[] { new WebsiteFileElementProviderEntityToken(castedEntityToken.Source, newFolderPath, castedEntityToken.RootPath) };
            }
            
            return new EntityToken[] { new WebsiteFileElementProviderRootEntityToken(castedEntityToken.Source, castedEntityToken.RootPath) };
        }
Exemplo n.º 5
0
        protected override void OnAddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext)
        {
            string url = this.UrlDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext);

            this.External = url.Contains("://");

            if(!External)
            {
                url = UrlUtils.ResolvePublicUrl(url);
            }

            CustomUrlActionNodeActionToken actionToken = new CustomUrlActionNodeActionToken(
                url,
                this.External,
                (this.External ? "externalview" : "documentview"),
                this.ViewLabelDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext),
                this.ViewToolTipDynamicValuesHelper.ReplaceValues(dynamicValuesHelperReplaceContext),
                this.Serialize(),
                this.PermissionTypes);

            ElementAction elementAction = new ElementAction(new ActionHandle(actionToken))
            {
                VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext)
            };

            actionAdder(elementAction);
        }
Exemplo n.º 6
0
        /// <exclude />
        public static SecurityResult Resolve(UserToken userToken, IEnumerable<PermissionType> requiredPermissions, EntityToken entityToken, IEnumerable<UserPermissionDefinition> userPermissionDefinitions, IEnumerable<UserGroupPermissionDefinition> userGroupPermissionDefinition)
        {
            if (userToken == null) throw new ArgumentNullException("userToken");
            if (requiredPermissions == null) throw new ArgumentNullException("requiredPermissions");

            if ((entityToken is NoSecurityEntityToken)) return SecurityResult.Allowed;

            requiredPermissions = requiredPermissions.Evaluate();

            if (!requiredPermissions.Any())
            {
                return SecurityResult.Allowed;
            }

            IEnumerable<PermissionType> currentPermissionTypes = PermissionTypeFacade.GetCurrentPermissionTypes(userToken, entityToken, userPermissionDefinitions, userGroupPermissionDefinition);

            if (!currentPermissionTypes.Any())
            {
                return SecurityResult.Disallowed;
            }

            // At least one of the permissions should be allowed
            foreach (PermissionType permissionType in currentPermissionTypes)
            {
                if (requiredPermissions.Contains(permissionType))
                {
                    return SecurityResult.Allowed;
                }
            }

            return SecurityResult.Disallowed;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Selects the specified element in the console
        /// </summary>
        /// <param name="consoleId">The console id.</param>
        /// <param name="entityToken">The entity token.</param>
        public static void SelectConsoleElement(string consoleId, EntityToken entityToken)
        {
            var serializedEntityToken = EntityTokenSerializer.Serialize(entityToken, true);

            var rootEntityToken = AttachingPoint.PerspectivesRoot.EntityToken;

            var refreshInfo = TreeServicesFacade.FindEntityToken(rootEntityToken, entityToken,
                new List<RefreshChildrenParams>(new[]
                {
                    new RefreshChildrenParams
                    {
                        ProviderName = rootEntityToken.Source,
                        EntityToken = EntityTokenSerializer.Serialize(rootEntityToken, true)
                    }
                }));

            if (refreshInfo == null || refreshInfo.Count == 0)
            {
                return;
            }

            string perspectiveElementKey = refreshInfo.Count > 1 ? refreshInfo[1].ElementKey : refreshInfo[0].ElementKey;

            var selectItem = new SelectElementQueueItem
            {
                EntityToken = serializedEntityToken,
                PerspectiveElementKey = perspectiveElementKey
            };

            ConsoleMessageQueueFacade.Enqueue(selectItem, consoleId);
        }
        public string TryGetUrl(EntityToken entityToken)
        {
            var dataEntityToken = entityToken as DataEntityToken;

            if (dataEntityToken == null)
            {
                return null;
            }

            var data = dataEntityToken.Data;
            if (data == null)
            {
                return null;
            }

            PageUrlData pageUrlData;

            var page = data as IPage;
            if (page != null)
            {
                pageUrlData = new PageUrlData(page);
            }
            else
            {
                pageUrlData = DataUrls.TryGetPageUrlData(data.ToDataReference());
            }

            return pageUrlData != null ? GetPagePreviewUrl(pageUrlData) : null;
        }
Exemplo n.º 9
0
        protected override IEnumerable<Element> OnGetElements(EntityToken parentEntityToken, TreeNodeDynamicContext dynamicContext)
        {
            var entityToken = new TreeSimpleElementEntityToken(
                this.Id, 
                this.Tree.TreeId, 
                EntityTokenSerializer.Serialize(parentEntityToken));                

            Element element = new Element(new ElementHandle(
                dynamicContext.ElementProviderName,
                entityToken,
                dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken)
                ));


            if (parentEntityToken is TreePerspectiveEntityToken)
            {
                element.ElementHandle.Piggyback[StringConstants.PiggybagTreeId] = Tree.TreeId;
            }

            var replaceContext = new DynamicValuesHelperReplaceContext(parentEntityToken, dynamicContext.Piggybag);

            element.VisualData = new ElementVisualizedData
            {
                Label = this.LabelDynamicValuesHelper.ReplaceValues(replaceContext),
                ToolTip = this.ToolTipDynamicValuesHelper.ReplaceValues(replaceContext),
                HasChildren = ChildNodes.Any(),
                Icon = this.Icon,
                OpenedIcon = this.OpenIcon
            };

            yield return element;
        }
Exemplo n.º 10
0
 internal AttachingPoint(AttachingPoint attachingPoint)
 {
     _entityToken = attachingPoint._entityToken;
     EntityTokenType = attachingPoint.EntityTokenType;
     Id = attachingPoint.Id;
     Source = attachingPoint.Source;
 }
        public IEnumerable<ElementAction> GetActions(EntityToken entityToken)
        {
            if (entityToken is NugetPackageEntityToken)
            {
                var isRemote = ((NugetPackageEntityToken)entityToken).IsRemotePackage();
                var isUpdate = ((NugetPackageEntityToken)entityToken).IsUpdatePackage();
                ElementAction elementAction = new ElementAction(new ActionHandle(new NugetActionToken()))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label =  isRemote ? "Install Package" : isUpdate? "Update Package" : "Uninstall Package",
                        ToolTip = string.Empty,
                        Icon = isRemote ? CommonCommandIcons.AddNew : isUpdate? CommonCommandIcons.Refresh : CommonCommandIcons.Delete,
                        ActionLocation = new ActionLocation
                        {
                            ActionType = ActionType.Edit,
                            IsInToolbar = true,
                            ActionGroup = AppendedActionGroup
                        }
                    }
                };
                yield return elementAction;

                

                

            } 
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var packageName = PackageCreatorFacade.ActivePackageName;
            if (entityToken is PackageCreatorEntityToken)
            {
                packageName = (entityToken as PackageCreatorEntityToken).Source;
            }
            if (string.IsNullOrEmpty(packageName))
            {
                flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
                var consoleServices = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
                consoleServices.ShowMessage(DialogType.Warning, PackageCreatorFacade.GetLocalization("NoPackages.Title"),
                                            PackageCreatorFacade.GetLocalization("NoPackages.Message"));
                return null;
            }

            if (actionToken is AddLocalizationActionToken)
            {
                var token = actionToken as AddLocalizationActionToken;
                PackageCreatorFacade.AddItem(new PCLocalizations(token.CultureName), packageName);
            }

            var treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);
            treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());

            return null;
        }
 public bool HaveCustomChildElements(EntityToken parentEntityToken,
                    Dictionary<string, string> piggybag)
 {
     if (ElementAttachingPointFacade.IsAttachingPoint(parentEntityToken,
       AttachingPoint.ContentPerspective) == false) return false;
     return true;
 }
        /// <exclude />
        public static bool IsAttachingPoint(EntityToken entityToken, AttachingPoint attachingPoint)
        {
            return attachingPoint.Id == entityToken.Id
                   && attachingPoint.Source == entityToken.Source
                   && attachingPoint.EntityTokenType == entityToken.GetType();

        }
Exemplo n.º 15
0
 public static IEnumerable<IPackItem> Create(EntityToken entityToken)
 {
     if (entityToken is GeneratedDataTypesElementProviderTypeEntityToken)
     {
         yield return new PCDynamicDataTypesData(entityToken);
     }
 }
		public IEnumerable<ElementAction> GetActions(EntityToken entityToken)
		{
			if (entityToken is DataEntityToken)
			{
				var token = entityToken as DataEntityToken;
				if (token.Data.DataSourceId.InterfaceType == typeof(ApiKey))
				{
					if (!token.Data.GetProperty<bool>("Default"))
					{
						yield return new ElementAction(new ActionHandle(new SetDefaultActionToken()))
						{
							VisualData = new ActionVisualizedData
							{
								Label = "Set Default",
								ToolTip = "Set Dafault",
								Icon = new ResourceHandle("Composite.Icons", "accept"),
								ActionLocation = new ActionLocation
								{
									ActionType = ActionType.Add,
									IsInFolder = false,
									IsInToolbar = true,
									ActionGroup = _actionGroup
								}
							}
						};
					}
				}
			}
		}
 /// <exclude />
 public static bool IsAttachingPoint(EntityToken leftEntityToken, EntityToken rightEntityToken)
 {
     return leftEntityToken.GetType() == rightEntityToken.GetType()
            && leftEntityToken.Id == rightEntityToken.Id
            && leftEntityToken.Type == rightEntityToken.Type
            && leftEntityToken.Source == rightEntityToken.Source;
 }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            //string documentTitle = "Unpublished Pages and Page Folder Data";
            //string description = "The list below display pages and page data which are currently being edited or are ready to be approved / published.";
            string documentTitle = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItems-document-title");
            string description = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItems-document-description");
            string emptyLabel = StringResourceSystemFacade.GetString("Composite.Plugins.GeneratedDataTypesElementProvider", "ViewUnpublishedItems-document-empty-label");
            string url = string.Format("{0}?showpagedata=true&title={1}&description={2}&emptyLabel={3}",
                UrlUtils.ResolveAdminUrl(string.Format("content/views/publishworkflowstatus/ViewUnpublishedItems.aspx")),
                HttpUtility.UrlEncode(documentTitle, Encoding.UTF8),
                HttpUtility.UrlEncode(description, Encoding.UTF8),
                HttpUtility.UrlEncode(emptyLabel, Encoding.UTF8));

            IManagementConsoleMessageService consoleServices = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
            OpenViewMessageQueueItem openViewMsg = new OpenViewMessageQueueItem
            {
                EntityToken = EntityTokenSerializer.Serialize(entityToken, true),
                ViewId = "ViewUnpublishedPageItems",
                Label = documentTitle,
                Url = url,
                ViewType = ViewType.Main
            };

            ConsoleMessageQueueFacade.Enqueue(openViewMsg, consoleServices.CurrentConsoleId);

            return null;
        }
 protected override void OnAddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext)
 {
     actionAdder(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.GenericDeleteDataWorkflow"), this.PermissionTypes)))
     {
         VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext)
     });
 }
        public IEnumerable<Element> GetChildren(EntityToken entityToken, SearchToken seachToken)
        {
            if (entityToken.Id == DeveloperApplicationProviderEntityToken.TreeRootFolderId)
            {
                foreach (string treeDefinitionFilename in this.TreeDefinitionFilenames)
                {
                    string filename = Path.GetFileName(treeDefinitionFilename);

                    Element treeDefintionElement = new Element(_context.CreateElementHandle(
                        new DeveloperApplicationProviderEntityToken(DeveloperApplicationProviderEntityToken.TreeDefinitionId, filename)))
                    {
                        VisualData = new ElementVisualizedData
                        {
                            Label = filename,
                            ToolTip = filename,
                            Icon = TreeDefinitionIcon
                        }
                    };

                    treeDefintionElement.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.DeleteTreeDefinitionWorkflow"), PermissionTypePredefined.Delete)))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "TreeDeleteTreeDefinitionWorkflow.Delete.Label"),
                            ToolTip = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "TreeDeleteTreeDefinitionWorkflow.Delete.ToolTip"),
                            Icon = TreeDefinitionIconDelete,
                            Disabled = false,
                            ActionLocation = ActionLocation.DeletePrimaryActionLocation
                        }
                    });

                    treeDefintionElement.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.EditTreeDefinitionWorkflow"), PermissionTypePredefined.Edit)))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "TreeDeleteTreeDefinitionWorkflow.Edit.Label"),
                            ToolTip = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "TreeDeleteTreeDefinitionWorkflow.Edit.ToolTip"),
                            Icon = TreeDefinitionIconEdit,
                            Disabled = false,
                            ActionLocation = ActionLocation.EditPrimaryActionLocation
                        }
                    });

                    yield return treeDefintionElement;
                }

                yield break;
            }
            else if (entityToken.Id == DeveloperApplicationProviderEntityToken.TreeDefinitionId)
            {
                //DeveloperApplicationProviderEntityToken castedEntityToken = (DeveloperApplicationProviderEntityToken)entityToken;

                //foreach (Element element in TreeFacade.GetElementsByTreeId(castedEntityToken.Filename, entityToken, new Dictionary<string, string>()))
                //{
                //    yield return element;
                //}
            }

            yield break;
        }
Exemplo n.º 21
0
        public TaskContainer CreateNewTasks(EntityToken entityToken, ActionToken actionToken, TaskManagerEvent taskManagerEvent)
        {
            List<Task> newTasks = new List<Task>();

            lock (_lock)
            {
                foreach (Func<EntityToken, ActionToken, Task> taskCreator in _taskCreators)
                {
                    try
                    {
                        Task task = taskCreator(entityToken, actionToken);
                        if (task == null) continue;

                        bool result = task.TaskManager.OnCreated(task.Id, taskManagerEvent);
                        if (result == false) continue;

                        _tasks.Add(task);
                        newTasks.Add(task);
                    }
                    catch (Exception ex)
                    {
                        Log.LogError("TaskManagerFacade", "Starting new task failed with following exception");
                        Log.LogError("TaskManagerFacade", ex);
                    }
                }
            }

            return new TaskContainer(newTasks, null);
        }
		public IEnumerable<ElementAction> GetActions(EntityToken entityToken)
		{
			if (entityToken is WebsiteFileElementProviderEntityToken)
			{
				if (Path.GetExtension(entityToken.Id).ToLower() == ".xml")
				{
					if (entityToken.Id.Replace("/", "\\").Contains(StoreHelper.StoringPath.Replace("/", "\\")))
					{
						yield return new ElementAction(new ActionHandle(new HandleActionToken()))
						{
							VisualData = new ActionVisualizedData
							{
								Label = "Export to Excel",
								ToolTip = "Export to Excel",
								Icon = new ResourceHandle("Composite.Icons", "mimetype-xls"),
								ActionLocation = new ActionLocation
								{
									ActionType = ActionType.Other,
									IsInFolder = false,
									IsInToolbar = false,
									ActionGroup = new ActionGroup("Export", ActionGroupPriority.PrimaryLow)
								}
							}
						};
					}
				}
			}
			yield break;
		}
 public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
 {
     PackageCreatorFacade.DeletePackageInformation(entityToken.Source);
     SpecificTreeRefresher treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);
     treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());
     return null;
 }
        public IEnumerable<ElementAction> GetActions(EntityToken entityToken)
        {
            var dataEntityToken = entityToken as DataEntityToken;
            if (dataEntityToken == null) return NoActions;

            if (dataEntityToken.InterfaceType != typeof(IXsltFunction)) return NoActions;

            var action = new ElementAction(new ActionHandle(new ConvertFunctionActionToken()))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = "Convert to Razor",
                    ToolTip = "Creates a new razor function with the same name and parameters while renaming the existing xsl function",
                    Icon = ActionIcon,
                    Disabled = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType = ActionType.Other,
                        IsInFolder = false,
                        IsInToolbar = true,
                        ActionGroup = PrimaryActionGroup
                    }
                }
            };

            return new [] { action };
        }
        public FlowToken Execute(EntityToken entityToken, ActionToken actionToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            var packageName = PackageCreatorFacade.ActivePackageName;

            if (entityToken is PackageCreatorEntityToken)
            {
                packageName = (entityToken as PackageCreatorEntityToken).Source;
            }
            if (string.IsNullOrEmpty(packageName))
            {
                flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
                IManagementConsoleMessageService consoleServices = flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();
                consoleServices.ShowMessage(DialogType.Warning, PackageCreatorFacade.GetLocalization("NoPackages.Title"), PackageCreatorFacade.GetLocalization("NoPackages.Message"));
                return null;
            }
            if (actionToken is PackageCreatorActionToken)
            {
                var token = actionToken as PackageCreatorActionToken;

                foreach (var item in PackageCreatorActionFacade.GetPackageCreatorItems(entityToken))
                {
                    if (item.CategoryName == token.CategoryName)
                    {
                        //if diffent item for one category and entitytoken
                        var itemActionToken = item as IPackItemActionToken;
                        if (itemActionToken != null)
                        {
                            if (token.Name != itemActionToken.ActionTokenName)
                            {
                                continue;
                            }
                        }
                        if (item is IPackToggle)
                        {
                            if ((item as IPackToggle).CheckedStatus == ActionCheckedStatus.Checked)
                            {
                                 PackageCreatorFacade.RemoveItem(item, packageName);
                            }
                            else
                            {
                                PackageCreatorFacade.AddItem(item, packageName);
                            }
                            var parentTreeRefresher = new ParentTreeRefresher(flowControllerServicesContainer);
                            parentTreeRefresher.PostRefreshMesseges(entityToken);
                        }
                        else
                        {
                            PackageCreatorFacade.AddItem(item, packageName);
                        }
                        break;
                    }
                }

            }

            SpecificTreeRefresher treeRefresher = new SpecificTreeRefresher(flowControllerServicesContainer);
            treeRefresher.PostRefreshMesseges(new PackageCreatorElementProviderEntityToken());

            return null;
        }
Exemplo n.º 26
0
        /// <exclude />
        public static Dictionary<string, string> PreparePiggybag(this Dictionary<string, string> piggybag, TreeNode parentNode, EntityToken parentEntityToken)
        {
            var newPiggybag = new Dictionary<string, string>();

            foreach (KeyValuePair<string, string> kvp in piggybag)
            {
                if (kvp.Key.StartsWith(ParentEntityTokenPiggybagString))
                {
                    int generation = int.Parse(kvp.Key.Substring(ParentEntityTokenPiggybagString.Length));

                    generation += 1;

                    newPiggybag.Add(string.Format("{0}{1}", ParentEntityTokenPiggybagString, generation), kvp.Value);
                }
                else if (kvp.Key.StartsWith(ParentNodeIdPiggybagString))
                {
                    int generation = int.Parse(kvp.Key.Substring(ParentNodeIdPiggybagString.Length));

                    generation += 1;

                    newPiggybag.Add(string.Format("{0}{1}", ParentNodeIdPiggybagString, generation), kvp.Value);
                }
                else
                {
                    newPiggybag.Add(kvp.Key, kvp.Value);
                }
            }

            newPiggybag.Add(string.Format("{0}1", ParentEntityTokenPiggybagString), EntityTokenSerializer.Serialize(parentEntityToken));
            newPiggybag.Add(string.Format("{0}1", ParentNodeIdPiggybagString), parentNode.Id.ToString());

            return newPiggybag;
        }
Exemplo n.º 27
0
        /// <summary>
        /// Posts refresh messages to the ancestors of the specified entityToken
        /// </summary>
        /// <param name="childEntityToken"></param>
        /// <param name="parentLevel">1 means the first parent, 2 means the second, etc.</param>
        public void PostRefreshMessages(EntityToken childEntityToken, int parentLevel = 1)
        {
            Verify.ArgumentNotNull(childEntityToken, "childEntityToken");

            if (_postRefreshMessagesCalled)
            {
                throw new InvalidOperationException("Only one PostRefreshMessages call is allowed");
            }

            _postRefreshMessagesCalled = true;

            RelationshipGraph relationshipGraph = new RelationshipGraph(childEntityToken, RelationshipGraphSearchOption.Both);

            var levels = relationshipGraph.Levels.Evaluate();

            if (levels.Count <= parentLevel)
            {
                return;
            }

            RelationshipGraphLevel relationshipGraphLevel = levels.ElementAt(parentLevel);

            IManagementConsoleMessageService messageService = _flowControllerServicesContainer.GetService<IManagementConsoleMessageService>();

            foreach (EntityToken entityToken in relationshipGraphLevel.AllEntities)
            {
                messageService.RefreshTreeSection(entityToken);
                Log.LogVerbose(this.GetType().Name, "Refreshing EntityToken: Type = {0}, Source = {1}, Id = {2}, EntityTokenType = {3}", entityToken.Type, entityToken.Source, entityToken.Id, entityToken.GetType());
            }
        }
Exemplo n.º 28
0
        public string CustomFormMarkupPath { get; internal set; }   // Optional


        /// <exclude />
        protected override void OnAddAction(Action<ElementAction> actionAdder, EntityToken entityToken, TreeNodeDynamicContext dynamicContext, DynamicValuesHelperReplaceContext dynamicValuesHelperReplaceContext)
        {
            var payload = new StringBuilder();
            this.Serialize(payload);

            StringConversionServices.SerializeKeyValuePair(payload, "_IconResourceName_", Icon.ResourceName);

            if (!String.IsNullOrEmpty(CustomFormMarkupPath))
            {
                StringConversionServices.SerializeKeyValuePair(payload, "_CustomFormMarkupPath_", CustomFormMarkupPath);

                actionAdder(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.GenericEditDataWorkflow"), this.PermissionTypes)
                            {
                                Payload = payload.ToString()
                            }))
                    {
                        VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext)
                    });
            }
            else
            {
                actionAdder(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Edit, this.PermissionTypes)))
                {
                    VisualData = CreateActionVisualizedData(dynamicValuesHelperReplaceContext)
                });
            }
        }
Exemplo n.º 29
0
        /// <exclude />
        public AddNewTreeRefresher(EntityToken parentEntityToken, FlowControllerServicesContainer flowControllerServicesContainer)
        {
            Verify.ArgumentNotNull(parentEntityToken, "parentEntityToken");
            Verify.ArgumentNotNull(flowControllerServicesContainer, "flowControllerServicesContainer");

            _beforeGraph = new RelationshipGraph(parentEntityToken, RelationshipGraphSearchOption.Both, false, false);
            _flowControllerServicesContainer = flowControllerServicesContainer;
        }
Exemplo n.º 30
0
        /// <exclude />
        public static SecurityResult Resolve(UserToken userToken, ActionToken actionToken, EntityToken entityToken, IEnumerable<UserPermissionDefinition> userPermissionDefinitions, IEnumerable<UserGroupPermissionDefinition> userGroupPermissionDefinition)
        {
            if (userToken == null) throw new ArgumentNullException("userToken");
            if (actionToken == null) throw new ArgumentNullException("actionToken");


            return Resolve(userToken, actionToken.PermissionTypes, entityToken, userPermissionDefinitions, userGroupPermissionDefinition);
        }
Exemplo n.º 31
0
        private static IReadOnlyCollection <PermissionType> RecursiveUpdateCurrentUserPermissionTypes(UserToken userToken, EntityToken entityToken, IEnumerable <UserPermissionDefinition> userPermissionDefinitions, HashSet <EntityTokenPair> alreadyProcessedTokens)
        {
            var cached = PermissionTypeFacadeCaching.GetUserPermissionTypes(userToken, entityToken);

            if (cached != null)
            {
                return(cached);
            }

            UserPermissionDefinition userPermissionDefinition = userPermissionDefinitions
                                                                .Where(f => entityToken.EqualsWithVersionIgnore(f.EntityToken)).SingleOrDefaultOrException("More then one UserPermissionDefinition for the same entity token");

            var thisPermissionTypes = new List <PermissionType>();

            if (userPermissionDefinition != null)
            {
                thisPermissionTypes.AddRange(userPermissionDefinition.PermissionTypes);
            }


            if (thisPermissionTypes.Count > 0)
            {
                thisPermissionTypes = thisPermissionTypes.Distinct().ToList();

                if (thisPermissionTypes.Contains(PermissionType.ClearPermissions))
                {
                    thisPermissionTypes = new List <PermissionType>();
                }

                PermissionTypeFacadeCaching.SetUserPermissionTypes(userToken, entityToken, thisPermissionTypes);

                // Local defined permission overrules all other permissions
                return(thisPermissionTypes);
            }

            // Call resursively on all parents
            var parentEntityTokens = ParentsFacade.GetAllParents(entityToken);

            var parentsPermissionTypes = Enumerable.Empty <PermissionType>();

            foreach (var parentEntityToken in parentEntityTokens)
            {
                var pair = new EntityTokenPair(entityToken, parentEntityToken);
                if (alreadyProcessedTokens.Contains(pair))
                {
                    continue;
                }

                alreadyProcessedTokens.Add(pair);

                var thisParentPermissionTypes = RecursiveUpdateCurrentUserPermissionTypes(userToken, parentEntityToken, userPermissionDefinitions, alreadyProcessedTokens);
                var filteredPermissions       = FilterParentPermissions(userToken, parentEntityToken, thisParentPermissionTypes);

                parentsPermissionTypes = parentsPermissionTypes.Concat(filteredPermissions);
            }

            List <PermissionType> permissionTypes = parentsPermissionTypes.Distinct().ToList();

            PermissionTypeFacadeCaching.SetUserPermissionTypes(userToken, entityToken, permissionTypes);

            return(permissionTypes);
        }
        /// <summary>
        /// This method will return all allowed permission for the given <paramref name="userToken"/> and given the <paramref name="entityToken"/>.
        /// </summary>
        /// <param name="userToken">UserToken to get permissions for.</param>
        /// <param name="entityToken">EntityToken to get permissions for.</param>
        /// <returns>Allowed permission types</returns>
        public static IEnumerable <PermissionType> GetPermissions(UserToken userToken, EntityToken entityToken)
        {
            IEnumerable <UserPermissionDefinition>      userPermissionDefinitions      = PermissionTypeFacade.GetUserPermissionDefinitions(userToken.Username);
            IEnumerable <UserGroupPermissionDefinition> userGroupPermissionDefinitions = PermissionTypeFacade.GetUserGroupPermissionDefinitions(userToken.Username);

            IEnumerable <PermissionType> permissions = PermissionTypeFacade.GetCurrentPermissionTypes(userToken, entityToken, userPermissionDefinitions, userGroupPermissionDefinitions).Evaluate();

            return(permissions);
        }
        /// <summary>
        /// This method will return all allowed permission for the current logged in user given the <paramref name="entityToken"/>.
        /// </summary>
        /// <param name="entityToken">EntityToken to get permissions for.</param>
        /// <returns>Allowed permission types</returns>
        public static IEnumerable <PermissionType> GetPermissionsForCurrentUser(EntityToken entityToken)
        {
            UserToken userToken = UserValidationFacade.GetUserToken();

            return(GetPermissions(userToken, entityToken));
        }
Exemplo n.º 34
0
        /// <exclude />
        public EntityTokenHook(EntityToken hooker)
        {
            Verify.ArgumentNotNull(hooker, "hooker");

            this.Hooker = hooker;
        }
Exemplo n.º 35
0
 /// <exclude />
 public bool Equals(EntityToken entityToken)
 {
     return(Equals(entityToken as object));
 }
Exemplo n.º 36
0
 /// <summary>
 /// This returns a merged result of user permissions and user group permissions
 /// </summary>
 /// <param name="userToken"></param>
 /// <param name="entityToken"></param>
 /// <returns></returns>
 public static IEnumerable <PermissionType> GetInheritedPermissionsTypes(UserToken userToken, EntityToken entityToken)
 {
     return(GetInheritedPermissionsTypes(userToken, entityToken, null));
 }
Exemplo n.º 37
0
        /// <exclude />
        public void AddHookie(EntityToken hook)
        {
            Verify.ArgumentNotNull(hook, "hook");

            _hooks.Add(hook);
        }
Exemplo n.º 38
0
        /// <exclude />
        public static IEnumerable <PermissionType> GetInheritedGroupPermissionsTypes(Guid userGroupId, EntityToken entityToken)
        {
            IEnumerable <UserGroupPermissionDefinition> userGroupPermissionDefinitions = GetUserGroupPermissionDefinitions(userGroupId);

            List <EntityToken> parentEntityTokens = ParentsFacade.GetAllParents(entityToken);

            List <PermissionType> permissionTypes = new List <PermissionType>();

            foreach (EntityToken parentEntityToken in parentEntityTokens)
            {
                permissionTypes.AddRange(GetInheritedGroupPermissionsTypesRecursivly(parentEntityToken, userGroupPermissionDefinitions));
            }

            return(permissionTypes.Distinct());
        }
Exemplo n.º 39
0
        /// <summary>
        /// This returns a merged result of user permissions and user group permissions
        /// </summary>
        /// <param name="userToken"></param>
        /// <param name="entityToken"></param>
        /// <param name="presetUserGroupPermissions">
        /// This is used for simulating that local defined user group permissions has been set
        /// </param>
        /// <returns></returns>
        public static IEnumerable <PermissionType> GetInheritedPermissionsTypes(UserToken userToken, EntityToken entityToken, Dictionary <Guid, IEnumerable <PermissionType> > presetUserGroupPermissions)
        {
            if (userToken == null)
            {
                throw new ArgumentNullException("userToken");
            }
            if (entityToken == null)
            {
                throw new ArgumentNullException("entityToken");
            }

            IEnumerable <PermissionType> permissionTypes = PermissionTypeFacadeCaching.GetInheritedPermissionsTypes(userToken, entityToken);

            if (permissionTypes != null)
            {
                return(permissionTypes);
            }

            if (presetUserGroupPermissions == null || presetUserGroupPermissions.Count == 0)
            {
                ICollection <PermissionType> localDefinedUserGroupPermissionTypes = GetLocallyDefinedUserGroupPermissionTypes(userToken.Username, entityToken).Evaluate();
                if (localDefinedUserGroupPermissionTypes.Count > 0)
                {
                    PermissionTypeFacadeCaching.SetInheritedPermissionsTypes(userToken, entityToken, localDefinedUserGroupPermissionTypes.ToList());
                    return(localDefinedUserGroupPermissionTypes);
                }
            }
            else
            {
                List <Guid> userGroupIds = UserGroupFacade.GetUserGroupIds(userToken.Username);

                var localDefinedUserGroupPermissionTypes = new List <PermissionType>();
                foreach (Guid userGroupId in userGroupIds)
                {
                    IEnumerable <PermissionType> groupPermissionTypes;
                    if (presetUserGroupPermissions.TryGetValue(userGroupId, out groupPermissionTypes))
                    {
                        localDefinedUserGroupPermissionTypes.AddRange(groupPermissionTypes);
                    }
                }

                if (localDefinedUserGroupPermissionTypes.Contains(PermissionType.ClearPermissions))
                {
                    return(new PermissionType[0]);
                }

                return(localDefinedUserGroupPermissionTypes.Distinct());
            }

            ICollection <UserPermissionDefinition>      userPermissionDefinitions      = GetUserPermissionDefinitions(userToken.Username).Evaluate();
            ICollection <UserGroupPermissionDefinition> userGroupPermissionDefinitions = GetUserGroupPermissionDefinitions(userToken.Username).Evaluate();

            List <EntityToken> parentEntityTokens = ParentsFacade.GetAllParents(entityToken);

            foreach (EntityToken parentEntityToken in parentEntityTokens)
            {
                RecursiveUpdateCurrentUserPermissionTypes(userToken, parentEntityToken, userPermissionDefinitions, new HashSet <EntityTokenPair>());
                RecursiveUpdateCurrentUserGroupPermissionTypes(userToken, parentEntityToken, userGroupPermissionDefinitions, new HashSet <EntityTokenPair>());
            }


            if (!PermissionTypeFacadeCaching.CachingWorking)
            {
                throw new InvalidOperationException("RequestLifetimeCache is not operational");
            }


            permissionTypes = new List <PermissionType>();
            foreach (EntityToken parentEntityToken in parentEntityTokens)
            {
                IEnumerable <PermissionType> parentUserPermissionTypes = PermissionTypeFacadeCaching.GetUserPermissionTypes(userToken, parentEntityToken);
                if (parentUserPermissionTypes != null)
                {
                    permissionTypes = permissionTypes.Concat(parentUserPermissionTypes);
                }

                IEnumerable <PermissionType> parentUserGroupPermissionTypes = PermissionTypeFacadeCaching.GetUserGroupPermissionTypes(userToken, parentEntityToken);
                if (parentUserGroupPermissionTypes != null)
                {
                    permissionTypes = permissionTypes.Concat(parentUserGroupPermissionTypes);
                }
            }

            var distinctPermissionTypes = permissionTypes.Distinct().ToList();

            PermissionTypeFacadeCaching.SetInheritedPermissionsTypes(userToken, entityToken, distinctPermissionTypes);

            return(distinctPermissionTypes);
        }
Exemplo n.º 40
0
        /// <exclude />
        public static IEnumerable <PermissionType> GetLocallyDefinedUserGroupPermissionTypes(Guid userGroupId, EntityToken entityToken)
        {
            Verify.ArgumentNotNull(userGroupId, "userGroupId");
            Verify.ArgumentNotNull(entityToken, "entityToken");

            IEnumerable <UserGroupPermissionDefinition> userGroupPermissionDefinitions = GetUserGroupPermissionDefinitions(userGroupId);

            var result = new List <PermissionType>();

            foreach (UserGroupPermissionDefinition userGroupPermissionDefinition in userGroupPermissionDefinitions)
            {
                if (userGroupPermissionDefinition.EntityToken.Equals(entityToken))
                {
                    result.AddRange(userGroupPermissionDefinition.PermissionTypes);
                }
            }

            return(result.Distinct());
        }
 /// <exclude />
 public static IEnumerable <EntityToken> GetParents(EntityToken entityToken)
 {
     return(_implementation.GetParents(entityToken));
 }
Exemplo n.º 42
0
        /// <summary>
        /// This returns a merged result of user permissions and user group permissions
        /// </summary>
        /// <param name="userToken"></param>
        /// <param name="entityToken"></param>
        /// <param name="userPermissionDefinitions"></param>
        /// <param name="userGroupPermissionDefinitions"></param>
        /// <returns></returns>
        public static IEnumerable <PermissionType> GetCurrentPermissionTypes(UserToken userToken, EntityToken entityToken, IEnumerable <UserPermissionDefinition> userPermissionDefinitions, IEnumerable <UserGroupPermissionDefinition> userGroupPermissionDefinitions)
        {
            Verify.ArgumentNotNull(userToken, "userToken");
            Verify.ArgumentNotNull(entityToken, "entityToken");

            IReadOnlyCollection <PermissionType> resultPermissionTypes = PermissionTypeFacadeCaching.GetCurrentPermissionTypes(userToken, entityToken);

            if (resultPermissionTypes != null)
            {
                return(resultPermissionTypes);
            }

            IReadOnlyCollection <PermissionType> userPermissionTypes = PermissionTypeFacadeCaching.GetUserPermissionTypes(userToken, entityToken);

            if (userPermissionTypes == null)
            {
                userPermissionTypes = RecursiveUpdateCurrentUserPermissionTypes(userToken, entityToken, userPermissionDefinitions, new HashSet <EntityTokenPair>());

                PermissionTypeFacadeCaching.SetUserPermissionTypes(userToken, entityToken, userPermissionTypes);
            }

            IReadOnlyCollection <PermissionType> userGroupPermissionTypes = PermissionTypeFacadeCaching.GetUserGroupPermissionTypes(userToken, entityToken);

            if (userGroupPermissionTypes == null)
            {
                userGroupPermissionTypes = RecursiveUpdateCurrentUserGroupPermissionTypes(userToken, entityToken, userGroupPermissionDefinitions, new HashSet <EntityTokenPair>());

                PermissionTypeFacadeCaching.SetUserGroupPermissionTypes(userToken, entityToken, userGroupPermissionTypes);
            }

            resultPermissionTypes = new List <PermissionType>(userPermissionTypes.Concat(userGroupPermissionTypes).Distinct());

            if (resultPermissionTypes.Contains(PermissionType.ClearPermissions))
            {
                resultPermissionTypes = EmptyPermissionTypeCollection;
            }

            PermissionTypeFacadeCaching.SetCurrentPermissionTypes(userToken, entityToken, resultPermissionTypes);

            return(resultPermissionTypes);
        }
Exemplo n.º 43
0
 public EntityTokenPair(EntityToken firstEntityToken, EntityToken secondEntityToken)
 {
     this.FirstEntityToken  = firstEntityToken;
     this.SecondEntityToken = secondEntityToken;
 }
Exemplo n.º 44
0
        private static IEnumerable <PermissionType> GetInheritedGroupPermissionsTypesRecursivly(EntityToken entityToken, IEnumerable <UserGroupPermissionDefinition> userGroupPermissionDefinitions, List <EntityToken> visitedParents = null)
        {
            UserGroupPermissionDefinition selectedUserGroupPermissionDefinition = userGroupPermissionDefinitions.Where(f => entityToken.Equals(f.EntityToken)).SingleOrDefault();

            if (selectedUserGroupPermissionDefinition != null)
            {
                if (selectedUserGroupPermissionDefinition.PermissionTypes.Contains(PermissionType.ClearPermissions) == false)
                {
                    foreach (PermissionType permissionType in selectedUserGroupPermissionDefinition.PermissionTypes)
                    {
                        yield return(permissionType);
                    }
                }

                yield break;
            }

            List <EntityToken> parentEntityTokens = ParentsFacade.GetAllParents(entityToken);

            if (visitedParents == null)
            {
                visitedParents = new List <EntityToken>();
            }

            IEnumerable <PermissionType> parentsPermisstionTypes = new List <PermissionType>();

            foreach (EntityToken parentEntityToken in parentEntityTokens)
            {
                if (visitedParents.Contains(parentEntityToken))
                {
                    continue;
                }
                visitedParents.Add(parentEntityToken);

                IEnumerable <PermissionType> result = GetInheritedGroupPermissionsTypesRecursivly(parentEntityToken, userGroupPermissionDefinitions, visitedParents).ToList();

                parentsPermisstionTypes = parentsPermisstionTypes.Concat(result);
            }

            foreach (PermissionType permissionType in parentsPermisstionTypes.Distinct())
            {
                yield return(permissionType);
            }
        }
        /// <exclude />
        public static SecurityResult Resolve(UserToken userToken, ActionToken actionToken, EntityToken entityToken, IEnumerable <UserPermissionDefinition> userPermissionDefinitions, IEnumerable <UserGroupPermissionDefinition> userGroupPermissionDefinition)
        {
            if (userToken == null)
            {
                throw new ArgumentNullException("userToken");
            }
            if (actionToken == null)
            {
                throw new ArgumentNullException("actionToken");
            }


            return(Resolve(userToken, actionToken.PermissionTypes, entityToken, userPermissionDefinitions, userGroupPermissionDefinition));
        }
        /// <exclude />
        public static SecurityResult Resolve(UserToken userToken, IEnumerable <PermissionType> requiredPermissions, EntityToken entityToken, IEnumerable <UserPermissionDefinition> userPermissionDefinitions, IEnumerable <UserGroupPermissionDefinition> userGroupPermissionDefinition)
        {
            if (userToken == null)
            {
                throw new ArgumentNullException("userToken");
            }
            if (requiredPermissions == null)
            {
                throw new ArgumentNullException("requiredPermissions");
            }

            if ((entityToken is NoSecurityEntityToken))
            {
                return(SecurityResult.Allowed);
            }

            requiredPermissions = requiredPermissions.Evaluate();

            if (!requiredPermissions.Any())
            {
                return(SecurityResult.Allowed);
            }

            IEnumerable <PermissionType> currentPermissionTypes = PermissionTypeFacade.GetCurrentPermissionTypes(userToken, entityToken, userPermissionDefinitions, userGroupPermissionDefinition);

            if (!currentPermissionTypes.Any())
            {
                return(SecurityResult.Disallowed);
            }

            // At least one of the permissions should be allowed
            foreach (PermissionType permissionType in currentPermissionTypes)
            {
                if (requiredPermissions.Contains(permissionType))
                {
                    return(SecurityResult.Allowed);
                }
            }

            return(SecurityResult.Disallowed);
        }
        /// <exclude />
        public static string Serialize(EntityToken entityToken, bool includeHashValue)
        {
            Verify.ArgumentNotNull(entityToken, "entityToken");

            return(CompositeJsonSerializer.Serialize(entityToken, includeHashValue));
        }
 public CacheEntry(EntityToken entityToken)
 {
     this.EntityToken = entityToken;
 }
Exemplo n.º 49
0
 /// <exclude />
 public RelationshipGraph(EntityToken sourceEntityToken, RelationshipGraphSearchOption searchOption, bool lazyEvaluation)
     : this(sourceEntityToken, searchOption, lazyEvaluation, true)
 {
 }
 /// <exclude />
 public static string Serialize(EntityToken entityToken)
 {
     return(Serialize(entityToken, false));
 }
Exemplo n.º 51
0
 private RelationshipOrientedGraphNode CreateNewNode(EntityToken entityToken)
 {
     return(new RelationshipOrientedGraphNode(entityToken, Expand));
 }
Exemplo n.º 52
0
 /// <exclude />
 public RelationshipOrientedGraphNode(EntityToken entityToken, Action <RelationshipOrientedGraphNode> expandAction)
 {
     this.EntityToken = entityToken;
     _expandAction    = expandAction;
 }
Exemplo n.º 53
0
        /// <exclude />
        public static IEnumerable <PermissionType> GetLocallyDefinedUserGroupPermissionTypes(string username, EntityToken entityToken)
        {
            List <Guid> userGroupIds = UserGroupFacade.GetUserGroupIds(username);

            IEnumerable <PermissionType> permissionTypes = new List <PermissionType>();

            foreach (Guid userGroupId in userGroupIds)
            {
                IEnumerable <PermissionType> localPermissionTypes = GetLocallyDefinedUserGroupPermissionTypes(userGroupId, entityToken);
                permissionTypes = permissionTypes.Concat(localPermissionTypes);
            }

            return(permissionTypes.Distinct());
        }
Exemplo n.º 54
0
 /// <exclude />
 public RelationshipGraph(EntityToken sourceEntityToken, RelationshipGraphSearchOption searchOption)
     : this(sourceEntityToken, searchOption, false, true)
 {
 }
Exemplo n.º 55
0
        private static IReadOnlyCollection <PermissionType> RecursiveUpdateCurrentUserGroupPermissionTypes(UserToken userToken, EntityToken entityToken, IEnumerable <UserGroupPermissionDefinition> userGroupPermissionDefinitions, HashSet <EntityTokenPair> alreadyProcessedTokens)
        {
            IReadOnlyCollection <PermissionType> cached = PermissionTypeFacadeCaching.GetUserGroupPermissionTypes(userToken, entityToken);

            if (cached != null)
            {
                return(cached);
            }

            IEnumerable <UserGroupPermissionDefinition> selectedUserGroupPermissionDefinitions = userGroupPermissionDefinitions.Where(f => entityToken.Equals(f.EntityToken));

            List <PermissionType> thisPermisstionTypes = new List <PermissionType>();

            foreach (UserGroupPermissionDefinition userGroupPermissionDefinition in selectedUserGroupPermissionDefinitions)
            {
                List <PermissionType> groupPermissionTypes = userGroupPermissionDefinition.PermissionTypes.ToList();

                thisPermisstionTypes.AddRange(groupPermissionTypes);
            }

            if (thisPermisstionTypes.Count > 0)
            {
                thisPermisstionTypes = thisPermisstionTypes.Distinct().ToList();

                if (thisPermisstionTypes.Contains(PermissionType.ClearPermissions))
                {
                    thisPermisstionTypes = new List <PermissionType>();
                }

                PermissionTypeFacadeCaching.SetUserGroupPermissionTypes(userToken, entityToken, thisPermisstionTypes);

                // Local defined permission overrules all other permissions
                return(thisPermisstionTypes);
            }

            // Call resursively on all parents
            List <EntityToken> parentEntityTokens = ParentsFacade.GetAllParents(entityToken);

            IEnumerable <PermissionType> parentsPermisstionTypes = new List <PermissionType>();

            foreach (EntityToken parentEntityToken in parentEntityTokens)
            {
                EntityTokenPair pair = new EntityTokenPair(entityToken, parentEntityToken);
                if (alreadyProcessedTokens.Contains(pair) == false)
                {
                    alreadyProcessedTokens.Add(pair);

                    IEnumerable <PermissionType> thisParentPermisstionTypes = RecursiveUpdateCurrentUserGroupPermissionTypes(userToken, parentEntityToken, userGroupPermissionDefinitions, alreadyProcessedTokens);

                    parentsPermisstionTypes = parentsPermisstionTypes.Concat(thisParentPermisstionTypes);
                }
            }

            List <PermissionType> permisstionTypes = parentsPermisstionTypes.Distinct().ToList();

            PermissionTypeFacadeCaching.SetUserGroupPermissionTypes(userToken, entityToken, permisstionTypes);

            return(permisstionTypes);
        }
Exemplo n.º 56
0
        /// <exclude />
        public RelationshipOrientedGraph(EntityToken sourceEntityToken)
        {
            RelationshipOrientedGraphNode node = CreateNewNode(sourceEntityToken);

            _nodes.Add(node);
        }