コード例 #1
0
        /// <summary>
        /// Removes the supplied group from a workspace.
        /// </summary>
        /// <param name="eddsWorkspaceArtifactID"></param>
        /// <param name="group"></param>
        /// <returns></returns>
        public bool RemoveGroupFromWorkspace(Int32 eddsWorkspaceArtifactID, kCura.Relativity.Client.DTOs.Group group)
        {
            bool          success = false;
            GroupSelector groupSelector;

            using (var permissionManager = _helper.GetServicesManager().CreateProxy <IPermissionManager>(API.ExecutionIdentity.System))
            {
                groupSelector = permissionManager.GetWorkspaceGroupSelectorAsync(eddsWorkspaceArtifactID).Result;
            }
            GroupRef groupRef = groupSelector.EnabledGroups.FirstOrDefault(x => x.Name == group.Name);

            if (groupRef != null)
            {
                GroupSelector modifyGroupSelector = new GroupSelector()
                {
                    LastModified = groupSelector.LastModified
                };
                modifyGroupSelector.DisabledGroups.Add(groupRef);
                using (var permissionManager = _helper.GetServicesManager().CreateProxy <IPermissionManager>(API.ExecutionIdentity.System))
                {
                    permissionManager.AddRemoveWorkspaceGroupsAsync(eddsWorkspaceArtifactID, modifyGroupSelector).Wait();
                }
                success = true;
            }

            return(success);
        }
コード例 #2
0
    /// <summary>
    /// Prints out the object permissions for one of the groups inside a given workspace
    /// </summary>
    /// <param name="mgr">Object that implements IPermissionManager</param>
    /// <param name="workspaceId">Artifact ID of the workspace whose permissions we want to read</param>
    /// <returns></returns>
    public static async Task PrintGroupPermissions(IPermissionManager mgr, int workspaceId)
    {
        // get an enabled group
        GroupSelector sel = await mgr.GetWorkspaceGroupSelectorAsync(workspaceId);

        if (sel.EnabledGroups.Count > 0)
        {
            GroupRef firstGroup = sel.EnabledGroups.FirstOrDefault();
            // get the permissions associated with said group
            GroupPermissions permissions = await mgr.GetWorkspaceGroupPermissionsAsync(workspaceId, firstGroup);

            // print out Object Permissions
            Console.WriteLine("Permissions for members of {0}", firstGroup.Name);
            foreach (ObjectPermission objPerm in permissions.ObjectPermissions)
            {
                Console.WriteLine("Object Name: {0}", objPerm.Name);
                // we could print out others, but let's just print out if group
                // members can edit the object (true/false)
                Console.WriteLine("Can Edit: {0}", objPerm.EditSelected);
                Console.WriteLine();
            }
        }
        else
        {
            Console.WriteLine("No groups enabled for this workspace ({0})", workspaceId);
        }
    }
コード例 #3
0
 public static void GroupCreate(
     GroupRef groupRef)
 {
     ThrowOut(
         SUGroupCreate(
             out groupRef.intPtr),
         "Could not create group.");
 }
コード例 #4
0
 public static void GroupGetEntities(
     GroupRef groupRef,
     EntitiesRef entitiesRef)
 {
     ThrowOut(
         SUGroupGetEntities(
             groupRef.intPtr,
             out entitiesRef.intPtr),
         "Could not get group entities.");
 }
コード例 #5
0
 public static void GroupSetName(
     GroupRef groupRef,
     string name)
 {
     ThrowOut(
         SUGroupSetName(
             groupRef.intPtr,
             name),
         "Could not set group name.");
 }
コード例 #6
0
 public static void GroupGetTransform(
     GroupRef groupRef,
     out Transformation trans)
 {
     ThrowOut(
         SUGroupGetTransform(
             groupRef.intPtr,
             out trans),
         "Could not get group transform.");
 }
コード例 #7
0
 public static void EntitiesAddGroup(
     EntitiesRef entitiesRef,
     GroupRef groupRef)
 {
     ThrowOut(
         SUEntitiesAddGroup(
             entitiesRef.intPtr,
             groupRef.intPtr),
         "Could not add group.");
 }
コード例 #8
0
 public static void GroupSetTransform(
     GroupRef groupRef,
     Transformation trans)
 {
     ThrowOut(
         SUGroupSetTransform(
             groupRef.intPtr,
             ref trans),
         "Could not set group transform.");
 }
コード例 #9
0
 public static void GroupGetName(
     GroupRef groupRef,
     StringRef stringRef)
 {
     ThrowOut(
         SUGroupGetName(
             groupRef.intPtr,
             out stringRef.intPtr),
         "Could not get group name.");
 }
コード例 #10
0
        public Task <Permission> Permission_ReadSingleAsync()
        {
            GroupRef          groupRef;
            Task <Permission> pv;

            using (IPermissionManager proxy = _helper.GetServicesManager().CreateProxy <IPermissionManager>(ExecutionIdentity.System))
            {
                groupRef = new GroupRef();
                pv       = proxy.ReadSingleAsync(_workspaceID, 44);
            }
            return(pv);
        }
コード例 #11
0
        /// <summary>
        /// Gets all the User IDs in the specific group designed for DynamicAPI
        /// </summary>
        /// <param name="serviceManager"></param>
        /// <param name="groupName"></param>
        /// <returns></returns>
        private async Task <List <int> > GetUsersInGroupByName(IServicesMgr serviceManager, string groupName)
        {
            List <int> userIds = new List <int>();

            using (IPermissionManager permissionManager = ConnectionHelper.Helper().GetServicesManager().CreateProxy <IPermissionManager>(ExecutionIdentity.System))
                using (IObjectManager objectManager = ConnectionHelper.Helper().GetServicesManager()
                                                      .CreateProxy <IObjectManager>(ExecutionIdentity.System))
                {
                    // Get Group id (from specified name)
                    Condition condition1 = new Relativity.Services.TextCondition(PermissionFieldNames.Name,
                                                                                 Relativity.Services.TextConditionEnum.EqualTo, groupName);

                    QueryRequest queryRequest = new QueryRequest()
                    {
                        ObjectType = new ObjectTypeRef()
                        {
                            ArtifactTypeID = Constants.ArtifactTypes.GroupId
                        },
                        Condition = condition1.ToQueryString()
                    };

                    QueryResult results =
                        await objectManager.QueryAsync(Constants.Connections.WorkspaceIdAdmin, queryRequest, 1, 100);

                    if (results.TotalCount == 0)
                    {
                        throw new Exception(
                                  $"Group ({groupName}) is not present in the instance of relativity. Create the group and add the user to this group to access DynamicAPI");
                    }

                    if (results.TotalCount > 1)
                    {
                        throw new Exception(Constants.Group.MultipleGroupsExist);
                    }

                    // Get list of users in that group
                    GroupRef       groupRef = new GroupRef(results.Objects.First().ArtifactID);
                    List <UserRef> users    =
                        await permissionManager.GetWorkspaceGroupUsersAsync(Constants.Connections.WorkspaceIdAdmin, groupRef);

                    if (users.Count == 0)
                    {
                        throw new Exception($"Not able to find any users in the group ({groupName})");
                    }

                    userIds = users.Select(x => x.ArtifactID).ToList();
                }

            return(userIds);
        }
コード例 #12
0
        public async Task <GroupInfo> GetGroupInfo(GroupRef groupRef)
        {
            int httpStatus;

            do
            {
                httpStatus = await _browserControl.LoadUrl(groupRef.Url);

                if (httpStatus > 500)
                {
                    await Task.Delay(10000);
                }
            } while (httpStatus > 500 || httpStatus < 200);

            if (httpStatus > 300)
            {
                return(new GroupInfo
                {
                    Name = groupRef.Name,
                    Description = "This group has been removed from Batoto. :(",
                    Delay = "Unknown",
                    Url = groupRef.Url,
                    Website = "Unknown"
                });
            }

            var result = await _browserControl.EvaluateScriptAsyncEx(Script.GetGroupInfo);

            var rawInfo = JsonConvert.DeserializeObject <KeyValuePair <string, string>[]>((string)result);

            var metaDataDict = rawInfo.ToDictionary(x => x.Key, x => x.Value);

            metaDataDict.TryGetValue("Website", out var website);
            metaDataDict.TryGetValue("Description", out var description);
            metaDataDict.TryGetValue("Delay", out var delay);

            return(new GroupInfo
            {
                Url = groupRef.Url,
                Name = groupRef.Name,
                Website = website,
                Description = description,
                Delay = delay
            });
        }
コード例 #13
0
ファイル: MenuBuilder.cs プロジェクト: vector-man/netide
        private object OnGroupRef(GroupRef groupRef)
        {
            INiCommandBarGroup commandGroup;

            ErrorUtil.ThrowOnFailure(_commandManager.FindCommandBarGroup(
                                         groupRef.Guid,
                                         out commandGroup
                                         ));

            if (commandGroup == null)
            {
                throw new NetIdeException(String.Format(NeutralResources.CannotFindCommandGroup, groupRef.Guid));
            }

            foreach (INiCommandBarControl control in Build(groupRef.Items))
            {
                ErrorUtil.ThrowOnFailure(commandGroup.Controls.Add(control));
            }

            return(commandGroup);
        }
コード例 #14
0
        public static bool RemoveGroupFromWorkspace(IPermissionManager permissionManager, Int32 eddsWorkspaceArtifactID, kCura.Relativity.Client.DTOs.Group group)
        {
            bool success = false;

            GroupSelector groupSelector = permissionManager.GetWorkspaceGroupSelectorAsync(eddsWorkspaceArtifactID).Result;
            GroupRef      groupRef      = groupSelector.EnabledGroups.FirstOrDefault(x => x.Name == group.Name);

            if (groupRef != null)
            {
                GroupSelector modifyGroupSelector = new GroupSelector()
                {
                    LastModified = groupSelector.LastModified
                };
                modifyGroupSelector.DisabledGroups.Add(groupRef);
                Task task = permissionManager.AddRemoveWorkspaceGroupsAsync(eddsWorkspaceArtifactID, modifyGroupSelector);
                task.ConfigureAwait(false);
                task.Wait();
                success = true;
            }

            return(success);
        }
コード例 #15
0
        public static void EntitiesGetGroups(
            EntitiesRef entitiesRef,
            long len,
            GroupRef[] groupRefs,
            out long count)
        {
            IntPtr[] intPtrs = new IntPtr[groupRefs.Length];

            ThrowOut(
                SUEntitiesGetGroups(
                    entitiesRef.intPtr,
                    len,
                    intPtrs,
                    out count),
                "Could not get entities groups.");

            for (int i = 0; i < groupRefs.Length; ++i)
            {
                groupRefs[i]        = new GroupRef();
                groupRefs[i].intPtr = intPtrs[i];
            }
        }
コード例 #16
0
        public static DrawingElementRef GroupToDrawingElement(
            GroupRef groupRef)
        {
            IntPtr intPtr = SUGroupToDrawingElement(groupRef.intPtr);

            if (intPtr == Invalid)
            {
                ThrowOut(
                    ErrorInvalidOutput,
                    "Could not cast group to drawing element.");

                return(null); // Never happens, but compiler wants it.
            }
            else
            {
                DrawingElementRef drawingElementRef = new DrawingElementRef();

                drawingElementRef.intPtr = intPtr;

                return(drawingElementRef);
            }
        }
コード例 #17
0
ファイル: PLBControlGroupref.cs プロジェクト: EddyK28/plbEdit
 public PLBControlGroupref(PLBNode nd) : base(nd)
 {
     groupRef = (GroupRef)node.item;
     InitializeComponent();
     InitData();
 }
コード例 #18
0
        // ******************************************************************************
        /// <summary>
        /// Adds this instance of GroupStructProp as group element and its children
        /// to a NewsML-G2 Package Item. The location in the group structure is
        /// defined by the PblPath property if this instance.
        /// </summary>
        /// <param name="pkgItem">The Package Item to which the group should be added</param>
        /// <returns>A PropProcStatus</returns>
        public virtual PropProcStatus AddGroupToPackage(PackageItemPwrXml pkgItem)
        {
            if (string.IsNullOrEmpty(PblPath))
            {
                return(PropProcStatus.ErrPkgNoPblPath);
            }
            if (string.IsNullOrEmpty(CoreGroup.role))
            {
                return(PropProcStatus.ErrPkgNoGroupRole);
            }

            var pblPathParsed = PblTools.ParsePblPath(PblPath);

            if ((pblPathParsed.EndNodeType == PblNodeType.ParseError) ||
                (pblPathParsed.EndNodeType == PblNodeType.Undefined))
            {
                return(PropProcStatus.ErrPkgNoPblPath);
            }

            string pblPath4Testing = string.Empty;

            // check if the hierarchical parent group(s) exist, skipped for the root group
            for (var idx = 0; idx < pblPathParsed.GroupRoles.Count - 1; idx++)
            {
                pblPath4Testing += "/" + pblPathParsed.GroupRoles[idx];
                if (!PblTools.PblNodeExists(pkgItem, pblPath4Testing))
                {
                    return(PropProcStatus.ErrPkgNoPblParentNode);
                }
            }

            pkgItem.AddGroupSet();                  // try to add it, skips action if it already exists

            if (string.IsNullOrEmpty(CoreGroup.id)) // take care that the group@id is not empty.
            {
                CoreGroup.id = pkgItem.NewIdSequence.ToString();
            }
            // adds the new group element
            pkgItem.AddNarPropertyToParent("/nar:packageItem/nar:groupSet", "", CoreGroup);

            ReadFromItemResultEnum readResult;

            if (pblPathParsed.GroupRoles.Count == 1) // this is the root group!
            {
                // apply the id of the root group to the root attribute of groupSet
                XmlElement groupSetXe = null;
                pkgItem.GetElemAsXE("/nar:packageItem/nar:groupSet", out groupSetXe, out readResult);
                if (readResult == ReadFromItemResultEnum.ok)
                {
                    groupSetXe.SetAttribute("root", CoreGroup.id);
                }
                // return PropProcStatus.ok; // exits here
            }
            else // ++2014-11-27
            {
                // for groups below the root in the hierarchy: add a groupRef element to the parent group
                var parentRole  = pblPathParsed.GroupRoles[pblPathParsed.GroupRoles.Count - 2];
                var newGroupRef = new GroupRef();
                newGroupRef.idref = CoreGroup.id;
                pkgItem.AddNarPropertyToParent("/nar:packageItem/nar:groupSet/nar:group[@role='" + parentRole + "']", "",
                                               newGroupRef);
            }

            // add all the child elements of the new group
            foreach (var itemRef in ItemRefs)
            {
                pkgItem.AddNarPropertyToParent("/nar:packageItem/nar:groupSet/nar:group[@id='" + CoreGroup.id + "']", "",
                                               itemRef);
            }
            foreach (var conceptRef in ConceptRefs)
            {
                pkgItem.AddNarPropertyToParent("/nar:packageItem/nar:groupSet/nar:group[@id='" + CoreGroup.id + "']", "",
                                               conceptRef);
            }
            foreach (var title in Titles)
            {
                pkgItem.AddNarPropertyToParent("/nar:packageItem/nar:groupSet/nar:group[@id='" + CoreGroup.id + "']", "",
                                               title);
            }
            foreach (var signal in Signals)
            {
                pkgItem.AddNarPropertyToParent("/nar:packageItem/nar:groupSet/nar:group[@id='" + CoreGroup.id + "']", "",
                                               signal);
            }
            foreach (var edNote in EdNotes)
            {
                pkgItem.AddNarPropertyToParent("/nar:packageItem/nar:groupSet/nar:group[@id='" + CoreGroup.id + "']", "",
                                               edNote);
            }
            foreach (var groupExtProperty in GroupExtProperties)
            {
                pkgItem.AddNarPropertyToParent("/nar:packageItem/nar:groupSet/nar:group[@id='" + CoreGroup.id + "']", "",
                                               groupExtProperty);
            }

            return(PropProcStatus.ok);
        } // AddGroupToPackage