public static Guid GetItemUniqueId(this IListItemDataService listItemDataService, string token, Guid listId)
        {
            if (string.IsNullOrEmpty(token))
            {
                return(Guid.Empty);
            }

            ItemBase listItem;

            // Try get item by incremental id
            int lookupId;

            if (int.TryParse(token, out lookupId) &&
                (listItem = listItemDataService.Get(lookupId, listId)) != null)
            {
                return(listItem.UniqueId);
            }

            // Try get item by contentKey
            if ((listItem = listItemDataService.Get(token, listId)) != null)
            {
                return(listItem.UniqueId);
            }

            return(Guid.Empty);
        }
        public string Document(Guid documentId)
        {
            ItemBase document;
            ListBase library;

            if ((document = listItemDataService.Get(documentId)) != null &&
                (library = listDataService.Get(document.ApplicationId)) != null &&
                library.GroupId > 0)
            {
                return(documentUrls.ViewDocument(library, document));
            }
            return(null);
        }
        public int[] GetViewSecurityRoles(Guid contentId)
        {
            var itemBase = listItemDataService.Get(contentId);

            if (itemBase != null)
            {
                var listBase = listDataService.Get(itemBase.ApplicationId);
                if (listBase != null)
                {
                    var group = TEApi.Groups.Get(new GroupsGetOptions {
                        Id = listBase.GroupId
                    });
                    var roles = TEApi.Roles.List(group.ApplicationId, SharePointPermissionIds.ViewLibrary);
                    return(roles.Any() ? roles.Select(r => r.Id.GetValueOrDefault()).ToArray() : new int[0]);
                }
            }
            return(new int[] { });
        }
        private Guid EnsureListId(Guid contentId)
        {
            var listId = SPCoreService.Context.ListId;

            if (listId != Guid.Empty)
            {
                return(listId);
            }

            var itemBase = ListItemDataService.Get(contentId);

            if (itemBase != null)
            {
                listId = itemBase.ApplicationId;
            }
            return(listId);
        }